deep
option must be specified.When using the watch
option to watch an array, the callback will only trigger when the array is replaced. In other words, the watch callback will no longer be triggered on array mutation. To trigger on mutation, the deep
option must be specified.
watch: { bookList: { handler(val, oldVal) { console.log('book list changed') }, deep: true }, }
If you rely on watching array mutations, add the deep
option to ensure that your callback is triggered correctly.
© 2013–present Yuxi Evan You
Licensed under the MIT License.
https://v3.vuejs.org/guide/migration/watch.html