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不提示代码,代码提示功能失效的解决方案
HBuilder不提示代码,代码提示功能失效的解决方案
2
WordPress隐藏修改后台登录地址插件WPS Hide Login的使用方法
WordPress隐藏修改后台登录地址插件WPS Hide Login的使用方法
3
神坑react native之unable to load script from assets 'index.android.bundle'报错的解决方法
神坑react native之unable to load script from assets 'index.android.bundle'报错的解决方法
4
Adobe系列软件安装时提示“安装失败 安装遇到错误”的解决方法
Adobe系列软件安装时提示“安装失败 安装遇到错误”的解决方法
5
EDIUS 8.53版本打开提示“由于意外错误,EDIUS已停止工作....”错误的解决方法
EDIUS 8.53版本打开提示“由于意外错误,EDIUS已停止工作....”错误的解决方法
最新评论
比比拉布
比比拉布
5月7日
太感谢了!!!!!!找了这么多的教程,只有你点出来了关键点——设计视图!!!!
Jake
Jake
3月7日
Halo 啊~麻烦更新下我的博客地址,原名:Jing Blog。麻烦更新如下: Jake Blog(后缀可以省略,也可以保留,看哪个风格适合) 网址:htt
评论于关于博主