0


Vue2 watch监听props的值

再次遇到监听子组件收到父组件传过来的值,如果这个值变化,页面中的值发现是不会跟着同步变化的。所以监听props中的值,一直监听。

代码:

 props: {
    start:{
       type: String,
    },
    end:{
       type: String,
    }
  },
    computed:{
     myStart:function(){
      return this.start
     },
          myEnd:function(){
      return this.end
     }
    },
      watch: {
    myStart:function(newVal){
      if(newVal){
        this.startTime=newVal
      }
      },
    myEnd:function(newVal){
      if(newVal){
        this.endTime=newVal
      }
      },
  },

本文转载自: https://blog.csdn.net/qq_46617584/article/details/129725226
版权归原作者 菜鸡上线 所有, 如有侵权,请联系我们删除。

“Vue2 watch监听props的值”的评论:

还没有评论