前提:已经装好webpack和vue,并配置好vue所需loader等
1.安装elementui
cnpm i element-ui -S
2.在main.js中引入elementui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);
此时运行后会报错
ERROR in ./node_modules/_element-ui@2.13.2@element-ui/lib/theme-chalk/fonts/element-icons.ttf 1:0
Module parse failed: Unexpected character ' ' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process
this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./node_modules/_element-ui@2.13.2@element-ui/lib/theme-chalk/index.css (./node_modules/css-loader/dist/cjs.js!./node_modules/_element-ui@2.13.2@element-ui/lib/theme-chalk/index.css) 5:0-70 8:73-102
@ ./node_modules/_element-ui@2.13.2@element-ui/lib/theme-chalk/index.css
@ ./src/main.js
3.需要在webpack中安装fileloader并配置相应规则
命令:cnpm install --save-dev file-loader
规则:
{
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loader: 'file-loader'
}