【发布时间】:2020-04-11 22:50:22
【问题描述】:
我需要将此脚本从 js 更改为 ts,但我需要 watchers 的语法
export default {
props: ['branch_id'],
watch: {}
}
【问题讨论】:
标签: typescript vue.js
我需要将此脚本从 js 更改为 ts,但我需要 watchers 的语法
export default {
props: ['branch_id'],
watch: {}
}
【问题讨论】:
标签: typescript vue.js
首先你必须声明你的变量,例如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.
}
}
【讨论】: