vue3引入ElementUI報錯問題及解決
更新時間:2024年07月08日 08:38:11 作者:MrLi-2018
這篇文章主要介紹了vue3引入ElementUI報錯問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
vue3引入ElementUI報錯
效果圖
下載依賴
npm install element-plus --save
引入方式
import ElementPlus from "element-plus" import 'element-plus/dist/index.css' createApp(App).use(store).use(router).use(ElementPlus).mount("#app");
完美解決報錯!?。?!
vue3引入element-ui報錯:Uncaught TypeError: Cannot read property‘prototype‘ of undefined
為什么
你寫的引入方式可能是這種
import ElementUI from "element-ui"; import "element-plus/lib/theme-chalk/index.css"; Vue.use(ElementUI)
配置無誤、代碼未報錯,運行時頁面空白,F(xiàn)12控制臺報錯:
Uncaught TypeError: Cannot read property ‘prototype’ of undefined
解決辦法
原因就是在main.js引入element-ui方式錯誤(vue3.0的坑)
先下載
npm install element-plus --save
vue3中正確引入方式如下
import ElementUI from "element-plus"; import "element-plus/dist/index.css" createApp(App).use(store).use(router).use(ElementUI).mount('#app')
一定要注意哦?。?! vue3是element-plus,然后重新啟動,解決!
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
axios 實現(xiàn)post請求時把對象obj數(shù)據(jù)轉(zhuǎn)為formdata
今天小編就為大家分享一篇axios 實現(xiàn)post請求時把對象obj數(shù)據(jù)轉(zhuǎn)為formdata,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10vue基礎(chǔ)之v-bind屬性、class和style用法分析
這篇文章主要介紹了vue基礎(chǔ)之v-bind屬性、class和style用法,結(jié)合實例形式分析了vue.js中v-bind綁定及class、style樣式控制相關(guān)操作技巧,需要的朋友可以參考下2019-03-03