vue2watch监听多个变量的值
vue2监听多个属性
·
利用computed和watch进行计算和监听
data () {
return {
username: '',
password: '',
isactive: ''
}
},
computed: {
listenChange () {
const {username,password} = this
return {username,password}
}
},
watch: {
listenChange (val) {
if (val.username== ""&&val.password=="") {
this.isactive=false
} else {
this.isactive=true
}
}
}
更多推荐
已为社区贡献10条内容
所有评论(0)