【发布时间】:2021-05-30 09:18:37
【问题描述】:
你能解释一下为什么当我在 Vue 3 中改变对象时没有调用watch。
相反,我需要完全替换对象。
https://codesandbox.io/s/nostalgic-glade-zer8v?file=/src/components/HelloWorld.vue
methods: {
change() {
// Triggers watch
this.user = { ...this.user, name: "hello" };
// Doesn't triger watch
this.user.name = "hello";
},
},
watch: {
user(nextUser) {
console.log(nextUser);
},
},
【问题讨论】:
标签: javascript vue.js vue-component vuejs3 vue-reactivity