需求:如果想监听对象 form中 属性 type的变化:

<script>
export default{
    data(){
        return{
            form:{
                name:"",
                type:""
            }
        }
    }
}
</script>

一、可以使用watch 结合 computed

computed:{
    type(){
        return this.form.type
    }        
},
watch:{
    type(val){
         console.log(val)
    }

二、使用 deep

watch:{
  form:{
      handler(newVal){
          console.log(newVal)
      },
      deep:true
  }

}
Logo

前往低代码交流专区

更多推荐