0
点赞
收藏
分享

微信扫一扫

vue的子组件在created里获取不到prop的值

ZSACH 2022-04-13 阅读 39
vue.js
props: {
    instance: {
      type: String,
      required: true
    }
  },

instanceID的值明明传过来了 但是在created里却获取不到

推荐写法 使用watch监听

 instance: function(newVal, _oldVal) {
      this.instanceId = newVal;
      //在这里调用 created 里面的函数
 }
举报

相关推荐

0 条评论