使用computed 和watch来同时监听多个属性值。。
data () {
return {
links: '',
categories: ''
}
},
computed: {
options () {
const { links, categories } = this
return { links, categories }
}
},
watch: {
options :{
deep:true,
handler(n,v){
console.log('n=========>',n);
}
}
}
参考原文:vue 使用watch同时监听多个属性
网友评论