Vue.component('todo-item', {
template: '<li>这是个待办项</li>'
})
vue组件注册需要放在new Vue对象之前,该组件才能正常使用。
var app6 = new Vue({
el: '#app-6',
data: {
message: 'Hello Vue!'
}
})
否则使用会提示
vue.js:634 [Vue warn]: Unknown custom element: <todo-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
网友评论