How does vue listen for variables
This article mainly introduces the relevant knowledge of how vue monitors variables, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this vue article on how to monitor variables. Let's take a look at it.
The specific steps are as follows:
1. First, create a new html project and introduce vue into the project
Import Vue from 'vue'
two。 After introducing vue, define a listening object in the project
Data: {
A: 1
B: 2
C: 3
D: 4
E: {
F: {
G: 5
}
}
}
3. Finally, after the listening object is defined, you can use the watch method to listen for variables in the object.
1) listen for variables
Watch: {
Bet (newValue, oldValue) {
Console.log (newValue)
}
}
2) listen to an object
Watch: {
'bet.text': function (val, oldVal) {}
}
Related extensions:
1) use the service method to listen on the entire object
ServiceList: {
Handler () {
Console.log (this.serviceList)
}
Deep:true
Immediate: true
}
This is the end of the article on "how to listen for variables in vue". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to monitor variables in vue". If you want to learn more, you are welcome to follow the industry information channel.