nuxt-community / nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
https://github.com/kaorun343/vue-property-decorator
MIT License
400 stars 34 forks source link

Adding `watchQuery` & `key` ? #13

Closed hartmut-co-uk closed 5 years ago

hartmut-co-uk commented 6 years ago

Hi, could we please add watchQuery & key?

please see https://github.com/nuxt/nuxt.js/blob/dev/examples/layout-transitions/pages/users.vue#L22-L25 and/or https://nuxtjs.org/api/pages-watchquery

hartmut-co-uk commented 6 years ago

Happy to contribute, can anyone point directions? Would/Should it need to be added to nuxt-class-component - and used in here to replace vue-class-component - as it's nuxt specific?

hartmut-co-uk commented 6 years ago

pls see https://cmty.app/nuxt/nuxt-class-component/issues/c8

breakingrobot commented 6 years ago

@hartmut-co-uk Please open a pull request, I will be happy to merge it asap :)

hartmut-co-uk commented 6 years ago

First need to find a solution :-) will have to wait for the issue raised with nuxt-class-component to respond I think.

Many thanks for the reply though!

hartmut-co-uk commented 5 years ago

note - I think this will all be covered/resolved with https://github.com/nuxt/nuxt.js/pull/4164

husayt commented 5 years ago

This is resolved with latest v2.1.3 We added

shalldie commented 5 years ago

watchQuery can't work with v2.1.3

I tried it like this:

import { Vue, Component } from 'nuxt-property-decorator';

@Component({
     ...
})
export default class IndexPage extends Vue {

    watchQuery: string[] = ['label', 'page'];
...

So strange, i see other hooks like asyncData works well, but watchQuery does nothing when query changes.

Ettapp commented 3 years ago

Better late than never: It should be put in the @Component decorator option parameter, like so:

@Component({
    watchQuery: ['label', 'page'],
})
export default class IndexPage extends Vue {
    // ...
}
shalldie commented 3 years ago

Better late than never: It should be put in the @Component decorator option parameter, like so:


@Component({

    watchQuery: ['label', 'page'],

})

export default class IndexPage extends Vue {

    // ...

}

Thx hahaha