Home > Article > Web Front-end > Usage examples of watch in vue (listening objects, data linkage)
The content of this article is about the usage examples of watch in Vue (monitoring objects, data linkage). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
When an element in the object changes, determine another element of the object and assign it
<template> <input type="text" v-model="a.a1.a12"/>{{a.a1.a12}} <input type="text" v-model="a.a2.a22"/>{{a.a2.a22}} </template> <script> data(){ retrun{ a:{ a1:{ a12:12 }, a2:{ a22:15 } } }, watch:{ a:{ handler(val.oldval){ if(val.a1.a12<val.a2.a22){ val.a2.a22=val.a1.a12; } }, deep:true } } </script>
Related recommendations:
Usage of Vue data monitoring method watch_vue.js
Small examples of data monitoring and data interaction in vue
The above is the detailed content of Usage examples of watch in vue (listening objects, data linkage). For more information, please follow other related articles on the PHP Chinese website!