[Vuejs]-What is the purpose of the "deep" flag on a watcher in Vue?

1👍

It detects nested changes to values of the object you are watching. From the docs:

vm.$watch('someObject', callback, {
  deep: true
})
vm.someObject.nestedValue = 123
// callback is fired

1👍

With a deep watcher you can be notified of the changes from nested attributes of the object.

If you watch a property declared as: property: {a: {b: 1}} without deep=true you won’t be notified of the changes of b but will be notified if you set deep=true

Leave a comment