Closed
Description
Version
2.7.14
Reproduction link
Steps to reproduce
Just open the codepen link, and open browser's devtool console
What is expected?
The Vue.set(obj, 'added', 1);
statement should trigger the watcher callback, which will print [watch getter]obj changed
.
What is actually happening?
nothing happened, the watcher does not be triggered
This behavior is not the same as neither vue2.6 or vue3.
Open this codepen writting with vue2.6+@vue/composition-api, It will print [watch getter]obj changed
, which is expected.
vue2.6+@vue/composition-api demo: https://codepen.io/AxisZ/pen/VwGeOEE
The core codes is here:
const { watch, reactive, set } = Vue;
const obj = reactive({ exist: 1 });
watch(
() => obj,
() => {
console.log('[watch getter]obj changed');
},
{ deep: true },
);
setTimeout(() => {
console.log('should print watcher message↓↓↓↓');
// add a new property, should trigger that watch below as expected
set(obj, 'added', 1);
});
Metadata
Metadata
Assignees
Labels
No labels