Unknown custom element did you register the component correctly

错误描述:

1 vue.esm.js?efeb:591 [Vue warn]: Unknown custom element: <el-container> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
2  
3 found in
4  
5 ---> <Container> at src/components/Container.vue
6        <App> at src/App.vue

2、错误原因

      没有在main.js文件中注册这个组件,导致出现了报错

3、解决办法

      在main.js中注册Container组件

 1 // The Vue build version to load with the `import` command
 2 // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
 3 import Vue from 'vue'
 4 import ElementUI from 'element-ui'
 5 import 'element-ui/lib/theme-chalk/index.css'
 6 import App from './App'
 7 import router from './router'
 8 import Container from '@/components/Container';
 9  
10 Vue.config.productionTip = false
11 Vue.use(ElementUI)
12  
13 /* eslint-disable no-new */
14 new Vue({
15   el: '#app',
16   router,
17   components: { App,Container },
18   template: '<App/>'
19 })

但是用了之后,还是不行,于是乎去了element-ui的官网

博主用的是按需引用,这边本地没有插件,所以采用了整体引入

 1 // The Vue build version to load with the `import` command
 2 // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
 3 import Vue from 'vue'
 4 import App from './App'
 5 import router from './router'
 6 import ElementUI from 'element-ui'
 7 import 'element-ui/lib/theme-chalk/index.css';
 8 
 9 Vue.config.productionTip = false
10 
11 Vue.use(ElementUI)
12 /* eslint-disable no-new */
13 new Vue({
14   el: '#app',
15   router,
16   components: { App},
17   template: '<App/>'
18 })

 

本文转自:https://blog.csdn.net/you23hai45/article/details/83014831

 

posted @ 2020-08-25 17:25  keepsummer  阅读(8362)  评论(0编辑  收藏  举报