Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does vue listen for variables

Shulou Source: shulou.com Published: 2022-05-31 13:24:58 10月04日 Update

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.

Tags: Monitoring variables objects knowledge projects contents methods articles value easy to operate articles easy to understand more steps look industry information channels channels learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker Apple OPPO Reno Microsoft