在vue开发的时候,调用组件后有如下报错:
[Vue warn]: Unknown custom element: <mycom1> - did you register the component correctly? For recursive components, make sure to provide the "name" option. (found in <Root>)
这个报错是因为找不到 mycom1 这个组件导致的,对于新手来说,这是个坑,因为vue要求如果创建组件时使用驼峰命名,调用组件的时候需要将驼峰改为横线-写法。
也就是说你创建组件的时候这样写,命名为 myCom1:
var app = new Vue({
el: '#app',
components: {
'myCom1': {
template: '<h1>我是myCom1组件</h1>'
}
}
})
调用的时候得写成 <my-com1></my-com1> 才行





