vue配置element-ui问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35746765/article/details/80817952

在学习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添加以下内容

[javascript]  view plain  copy
  1.   
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/[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可以顺利打开项目

猜你喜欢

转载自blog.csdn.net/qq_35746765/article/details/80817952