例如子组件里props:["str1","str2"]
watch怎么写才能监听这两个值
在 computed
中声明一个参数由这两个值更新,然后监听这个新值
computed: {
theValue() {
return {
str1: this.str1,
str2: this.str2,
};
},
},
watch: {
theValue(newVal, oldVal) {
console.log(newVal, oldVal);
},
},
9 回答1.7k 阅读✓ 已解决
6 回答1.7k 阅读
3 回答1.5k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.2k 阅读
2 回答1.3k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
直接添加多个就行
