首页 > 解决方案 > 元素 UI - 未知的自定义元素:- 您是否正确注册了组件?

问题描述

我用的是element ui模板,但是在添加el-drawer等一些组件的时候,在我看来好像没有注册,

https://element.eleme.io/#/es/component/drawer

vue.runtime.esm.js:574 [Vue warn]: Unknown custom element: <el-drawer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Dashboard>
       <AppMain> at src/layout/components/AppMain.vue
         <Layout> at src/layout/index.vue
           <App> at src/App.vue
             <Root>

如何添加或修复它?谢谢

模板:https ://github.com/PanJiaChen/vue-admin-template 参考:https ://element.eleme.io/#/es/component/quickstart#configuracion-global

main.js

/* eslint-disable */
import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import axios from 'axios'
import ElementUI from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
import { mockXHR } from '../mock'
if (process.env.NODE_ENV === 'production') {
  mockXHR()
}

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui,按如下方式声明
// Vue.use(ElementUI)

axios.defaults.baseURL='https://localhost:44340/'
//axios.defaults.baseURL='http://localhost/'
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

标签: javascriptvue.jsvue-componentelement

解决方案


推荐阅读