全局注册,注册的组件需要在初始化根实例之前注册了组件;
局部注册,通过使用组件实例选项注册,可以使组件仅在另一个组件或者实例的作用域中可用:
全局组件
js
Vue.component('tab-title',{
props:['title'],
template:'<li v-on:click=$emit(\>{{title}}</li>'
})
Vue.component('tab-content',{
props:['content'],
template:'<div>{{content}}</div>'
})
局部组件demo: