This time I will bring you the monitoring method watch. What are the precautions for using the monitoring method watch? The following is a practical case, let's take a look.
The watch itself is easy to understand. The watch is responsible for associating the data in the view with a certain function
When the data in the Vue view changes, the associated function will be executed
corresponds to an object, the key is the observation expression, and the value is the corresponding callback. The value can also be a method name, or an object containing options. Call $watch() for each key during instantiation;
//使用官方vue-cli脚手架书写 //观察数据为字符串或数组 /当单观察数据examples2为对象时,如果键值发生变化,为了监听到数据变化,需要添加deep:true参数
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
vue2 implements shopping cart address selection
jQuery can give priority to local preview when uploading images
The above is the detailed content of Listening method watch. For more information, please follow other related articles on the PHP Chinese website!