2. 组建的注册与引入

1.注册

Vue.component('my-header', {
  template: '<p>this is my header template</p>',
 data: function(){
  return ... // 组建里的数据一定要function return新的数据出去,不能直接用data: {}
 } })

2. 引用

a.在模版当中<my-header></my-header>

b.在vue实例化配置当中引入components

new Vue({
  el: '#app',
  components: {
    myheader
  }
})

  

 

posted @ 2017-03-24 16:14  涵叔  阅读(104)  评论(0)    收藏  举报