javascript - How to avoid TypeError when passing Object from parent component to child component in vue?
黄舟
黄舟 2017-07-05 10:38:07
0
3
760
父组件
<father :data="data"></father>
 data() {
      return {
        data: {}
      }
 }

 mounted() {
   this.data = {
     title: '标题'
   }
 }

 子组件
 <son>{{data.title}}<son>
  props: {
  data: Object,
}

报错: title属性 undefined
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
巴扎黑
<son v-if="data">{{data.title}}<son>
世界只因有你

Your initial data should be given the title attribute

大家讲道理

The writing method is no problem, https://jsfiddle.net/stardew/...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template