vue学习笔记16 component 组件 父子关系

<father></father>

声明一个对象,对象里就是组件的内容

子组件

var sun={

  template:`<p>我是儿子</p>`

}

父组件

var father={

  template:`

    <div>

      <p>我是父亲</p>

      <sun></sun>

    </div>

  `

  //父级里注册子级

  components:{

    "sun":sun

}

}

app构造器里

components:{

  "father":father

}

猜你喜欢

转载自www.cnblogs.com/laohange/p/12825693.html