1👍
This is the normal behaviour of props in Vue 2
They don’t "watch" down to deeper levels, by default.
Two solutions in Vue 2 from the docs: https://vuejs.org/guide/essentials/watchers.html#deep-watchers
1. Explicitly watch particular properties
watch: {
'some.nested.key'(newValue) {
// ...
}
}
2. Deep-watch the entire prop
export default {
watch: {
someObject: {
handler(newValue, oldValue) {
// Note: `newValue` will be equal to `oldValue` here
// on nested mutations as long as the object itself
// hasn't been replaced.
},
deep: true
}
}
}
See below for @yoduh’s excellent point about Vue 3 composition API doing deep watching by default.
- [Vuejs]-How to import mongo db in vue js 2?
- [Vuejs]-Nothing can go in between custom tags – <myTag_vue> … </> in vue js?
Source:stackexchange.com