vue组件无法使用报错

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.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,150评论 0 10
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,593评论 0 3
  • 组件(Component)是Vue.js最核心的功能,也是整个架构设计最精彩的地方,当然也是最难掌握的。...
    六个周阅读 10,932评论 0 32
  • 这篇笔记主要包含 Vue 2 不同于 Vue 1 或者特有的内容,还有我对于 Vue 1.0 印象不深的内容。关于...
    云之外阅读 10,460评论 0 29
  • 姓名:岳沁 学号:17101223458 转载自:https://www.cnblogs.com/tanlujia...
    丘之心阅读 2,934评论 0 1