我想在Vue中检测我的URL中的更改.使用TypeScript的js应用程序.在JavaScript中,这可以通过以下方式完成:
watch: {
'$route': {
handler: 'onUrlChange',
immediate: true,
deep: true
}
},
onUrlChange(newUrl){
// Some action
}
我怎么能在打字脚本中做同样的事情呢?
我想在Vue中检测我的URL中的更改.使用TypeScript的js应用程序.在JavaScript中,这可以通过以下方式完成:
watch: {
'$route': {
handler: 'onUrlChange',
immediate: true,
deep: true
}
},
onUrlChange(newUrl){
// Some action
}
我怎么能在打字脚本中做同样的事情呢?
我在这里找到了答案:https://github.com/kaorun343/vue-property-decorator
可以这样做:
@Watch('$route', { immediate: true, deep: true })
onUrlChange(newVal: any) {
// Some action
}