1.安装:
cnpm i element-ui -S
2.main .js 引入:
import ElementUI from 'element-ui';import 'element-ui/lib/theme-chalk/index.css';Vue.use(ElementUI);
3.运行报错:
ERROR in ./node_modules/_element-ui@2.4.2@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/_css-loader@0.28.11@css-loader!./node_modules/_element-ui@2.4.2@element-ui/lib/theme-chalk/index.css 7:411-447 @ ./node_modules/_element-ui@2.4.2@element-ui/lib/theme-chalk/index.css @ ./src/main.js @ multi ./node_modules/_webpack-dev-server@2.11.2@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
4.解决:在webpack.config.js里配置
{test: /\.(eot|svg|ttf|woff|woff2)$/,loader: 'file-loader'}
原文:https://blog.csdn.net/weixin_41587194/article/details/80275281