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

Categories

0 votes
887 views
in Technique[技术] by (71.8m points)

vue里面的prop传值

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

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


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

1 Answer

0 votes
by (71.8m points)
// 父组件
<child :show.sync='show'></child>

data () {
  return {
    show: false
  }
}

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

试试update,sync修饰符


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...