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");完美解決報錯?。。。?/p>
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,然后重新啟動,解決!
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Vue-Cli如何在index.html中進行環(huán)境判斷
這篇文章主要介紹了Vue-Cli如何在index.html中進行環(huán)境判斷問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-03-03
如何解決npm i下載依賴的時候出現(xiàn)某依賴版本沖突
這篇文章主要介紹了如何解決npm i 下載依賴的時候出現(xiàn)某依賴版本沖突問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-03-03
淺談Vuex的this.$store.commit和在Vue項目中引用公共方法
這篇文章主要介紹了淺談Vuex的this.$store.commit和在Vue項目中引用公共方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07

