Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

vue里面的prop传值是实时动态吗?

比如:在渲染子组件child以后,使用$emit传值到父组件修改父组件里面的prentData,然后在调用子组件的通过prop传值过来的刚刚修改的值,这时会获取到最新的值吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
725 views
Welcome To Ask or Share your Answers For Others

1 Answer

// 父组件
<child :show.sync='show'></child>

data () {
  return {
    show: false
  }
}

// 子组件
this.$emit('update: show', false)

试试update,sync修饰符


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...