Vue3.x 引入 element ui 报错 Uncaught TypeError: Cannot read property ‘prototype‘ of undefined
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
·
今天在使用Vue3.x 版本创建Vue脚手架, 并引入elementUi的时候,启动项目前端报错了。
- 创建Vue3.x 项目

- 添加element Ui 命令 npm i element-ui -S.
- 在main.js中引入element Ui
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
createApp(App).use(router).use(ElementUI).mount('#app')
- 运行项目 npm run serve
- 前台报错如下:

解决办法 :创建Vue项目的时候选择 Vue2.x 版本 其他操作不变。(版本原因,新版3.x 暂时还不支持ElementUI)
main.js文件为
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//导入并添加elment
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
1 年前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 1 年前
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐


所有评论(0)