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
}
})

浙公网安备 33010602011771号