vuewatch如何同时监听多个属性 第一种方法 data(){return{name1:'', name2:'', age:''}}, watch:{'name1':function(val){if(this.name1===this.name2){this.$set(this,'age',1)}else{this.$set(this,'age',null)}},'name2':function(val){if(this.name1===this.name2){this.$set(this...
data () {return{city:'',area:'',currentPage:''} },watch: {city:function(val) {// 写要执行的代码片段},area:function(newVal,oldVal) {// 写要执行的代码片段}, } 第二种 data() {return{ city:'', area:'', currentPage:''} }, computed: { listenChange () {const{ city, area, ...
1.先在computed里 computed:{dataChange(){const{method,methodData,gzjsTable2}=this;//需要监听的属性值return{method,methodData,gzjsTable2}}} 2.在watch里监听 watch:{dataChange:{handler(val){console.log(val);this.flagchange++//排除第一次进页面时会出发watch的情况// 默认值有变更的话if(this.fla...
vue中watch同时监听多个属性问题 分类:vue web_cnblogs 粉丝-0关注 -0 +加关注 0 0 升级成为会员 posted @2022-07-12 16:31web_cnblogs阅读(70) 评论(0)编辑收藏举报
vue watch如何同时监听多个属性 data () { return { name1: '', name2: '', age: '' } }, computed: { listenChange () { const {name1,name2} = this return {name1,name2} } }, watch: { listenChange (val) { console.log('listenChange :', val)...