vue watch 监听多个值

用computed定义一个address对象吧,然后再去watch addres

data() {
  return {
    check: false,
    sign_img: "",
    submit_flag: false'
  }
},
computed: {
  btnObj() {
    const { sign_img, check } = this
    return {
      sign_img,
      check
    }
  }
},
watch: {
  btnObj: {
    handler: function(newVal,oldVal) {
      if(!!this.sign_img && this.check){
        this.submit_flag = true
        this.sign_flag = '1'
      }else{
        this.submit_flag = false
        this.sign_flag = '0'
      }
    },
    deep: true,
    immediate: true
  }
}

猜你喜欢

转载自www.cnblogs.com/kevins-yuan/p/10310522.html