vue报错[Vue warn]: Unknown custom element: – did you register the component correctly? For recursive components, make sure to provide the “name” option.的解决方法

在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> 才行

 

 

 

 

 

关于博主
骨灰级博客玩家
国内第一批90后网站站长/程序员
做过七年前端讲师
目前从事锦鲤观赏鱼电商行业
鱼贝贝锦鲤创始人
文章列表
1
hbuilder编辑器无法自动编译less文件的终极解决方案之koala考拉解析器
hbuilder编辑器无法自动编译less文件的终极解决方案之koala考拉解析器
2
一点随感
一点随感
3
win7/8/10系统打不开chm手册文件的解决方法
win7/8/10系统打不开chm手册文件的解决方法
4
2008年做的灰鸽子,今天整理东西翻出来的
2008年做的灰鸽子,今天整理东西翻出来的
5
phpstudy启动报错nginx: [emerg] invalid number of arguments in "include" directive in 的解决方法
phpstudy启动报错nginx: [emerg] invalid number of arguments in "include" directive in 的解决方法
最新评论
比比拉布
比比拉布
5月7日
太感谢了!!!!!!找了这么多的教程,只有你点出来了关键点——设计视图!!!!
Jake
Jake
3月7日
Halo 啊~麻烦更新下我的博客地址,原名:Jing Blog。麻烦更新如下: Jake Blog(后缀可以省略,也可以保留,看哪个风格适合) 网址:htt
评论于关于博主