Reputation: 392
I need to change this script from js to ts but i need syntax of watchers
export default {
props: ['branch_id'],
watch: {}
}
Upvotes: 13
Views: 21666
Reputation: 3834
First you have to declare your variable, like myProperty
in this case, and then you have to make a @Watch('myProperty')
to make the actual watcher for that specific variable.
@Component
export default class App extends Vue {
myProperty: string
@Watch('myProperty')
onPropertyChanged(value: string, oldValue: string) {
// Do stuff with the watcher here.
}
}
Upvotes: 24