You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
const{ watch, reactive, set }=Vue;constobj=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 expectedset(obj,'added',1);});
The text was updated successfully, but these errors were encountered:
// if the return value is reactive and deep:true// watch for changes, this might happen when new key is addedif(isReactive(watcher.value)&&watcher.value.__ob__?.dep&&deep){watcher.value.__ob__.dep.addSub({update(){// this will force the source to be revaluated and the callback// executed if neededwatcher.run()},})}
Version
2.7.14
Reproduction link
codepen.io/AxisZ/pen/RwYrmxq
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:
The text was updated successfully, but these errors were encountered: