1. 程式人生 > >vue配置element-ui問題

vue配置element-ui問題

在學習vue期間,剛開始配置element-ui時總是遇到各種各樣的問題,記錄一下解決問題的一些大致思路,方便以後做專案,也希望對別人有所幫助。

1:vue init webpack-simple element-ui

2.cd element-ui(開啟生成的vue專案)

3.cnpm install (不用npm是個人習慣,防止產生錯誤)

4.在這裡我用的是webpack-simple 所以要先配置一下style-loader:cnpm install style-loader -S

5.配置安裝element-ui:cnpm install element-ui -S

6.安裝完成後用編輯器開啟專案,在main.js新增以下內容


import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
記得要全域性註冊

Vue.use(ElementUI)

做完這些後,我直接npm run dev,報了一個錯誤

./node_modules/[email protected]@element-ui/lib/theme-chalk/fonts/element-icons.ttfModule parse failed: Unexpected character '' (1:0)You may need an appropriate loader to handle this file type.(Source code omitted for this binary file) @ ./node_modules/

[email protected]@css-loader!./node_modules/[email protected]@element-ui/lib/theme-chalk/index.css 7:411-447 @ ./node_modules/[email protected]@element-ui/lib/theme-chalk/index.css @ ./src/main.js @ multi ./node_modules/_webp[email protected]@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

然後我查了好久發現要在webpack.config.js裡配置

{
  test: /\.(eot|svg|ttf|woff|woff2)$/,
  loader: 'file-loader'
},
最後npm run dev可以順利開啟專案
--------------------- 
作者:akang12138 
來源:CSDN 
原文:https://blog.csdn.net/weixin_41587194/article/details/80275281 
版權宣告:本文為博主原創文章,轉載請附上博文連結!