vue computed

computed:{
    areaAndDstri:{
      get:function (){
        return {
          areaId:this.areaId,
          districtId:this.districtId,
          dateTime:this.dateTime
        }
      }
    }
  },

 watch:{
    areaAndDstri(newV,oldV){
      console.log(newV)
      this.$emit('areaDstrId',newV)
    }
  },

在computed中被创建的属性可以 的data那样被使用和监听等一系列操作

在子组件中可以利用这个向父组件监听多个值只发送一次emit

https://cn.vuejs.org/v2/api/#computed

posted @ 2022-03-23 13:45  前端路远且长  阅读(56)  评论(0)    收藏  举报