-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watch()
doesn't trigger when adding new property with Vue.set( )
#12967
Comments
found // if the return value is reactive and deep:true
// watch for changes, this might happen when new key is added
if (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 needed
watcher.run()
},
})
} |
maybe related to vuejs/composition-api#933 |
13 tasks
xiaowei-one
pushed a commit
to xiaowei-one/vue
that referenced
this issue
Feb 28, 2023
xiaowei-one
pushed a commit
to xiaowei-one/vue
that referenced
this issue
Feb 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: