我需要将此脚本从js更改为ts,但我需要观察者的语法
export default {
props: ['branch_id'],
watch: {}
}
答案 0 :(得分:0)
首先,您必须声明您的变量,例如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.
}
}