利用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
        }
      }
}
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐