我需要将这个脚本从js改为ts,但我需要观察者的语法
export default {
props: ['branch_id'],
watch: {}
}
我需要将这个脚本从js改为ts,但我需要观察者的语法
export default {
props: ['branch_id'],
watch: {}
}
首先,你必须声明你的变量,比如本例中的myProperty
,然后你必须做一个@Watch('myProperty')
,为这个特定的变量创建一个实际的观察者.
@Component
export default class App extends Vue {
myProperty: string
@Watch('myProperty')
onPropertyChanged(value: string, oldValue: string) {
// Do stuff with the watcher here.
}
}