vue can listen for changes in data through watch. The usual way of writing is:
data: { a: 100 }, watch: { a(newval, oldVal) { // Do something. . . (newval, oldVal) } }
vue listens to the entire object, as follows:
•deep: true Depth monitoring
data: { return { msg: { name: 'hahah', color: 'red' } } } watch: { msg: { handler(newValue, oldValue) { // Do something. . . (newValue) }, deep: true }
If you listen to a specific property in the object, you can implement it by computed as an intermediate layer:
computed: { name() { return } }, watch:{ name(newValue, oldValue) { // Do something. . . (newval, oldVal) } }
Summarize
The above is the relevant knowledge about vue watch attribute monitoring introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time!