zoukankan      html  css  js  c++  java
  • vue-导入element-ui

    安装

    npm install element-ui -S

    项目中导入

    修改main.js

    import ElementUI from 'element-ui';
    import 'element-ui/lib/theme-chalk/index.css';
    
    Vue.use(ElementUI);
    
    new Vue({
        el: '#app',
        router,
        // components: { App },
        // template: '<App/>',
        render: h => h(App)
    })
    

    问题

    Module parse failed: Unexpected character ' '

    > npm run dev
    ERROR in ../node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf
    Module 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!../node_modules/element-ui/lib/theme-chalk/index.css 7:894-9304-930
     @ ../node_modules/element-ui/lib/theme-chalk/index.css
     @ ./src/main.js                                                                      c/main.js
     @ multi (webpack)-dev-server/client?http://localhost:7777 webpack/hot/dev-server ./src/main.js
    
    ERROR in ../node_modules/element-ui/lib/theme-chalk/fonts/element-icons.woff
    Module parse failed: Unexpected character ' ' (1:4)
    You may need an appropriate loader to handle this file type.
    (Source code omitted for this binary file)
     @ ./node_modules/css-loader!../node_modules/element-ui/lib/theme-chalk/index.css 7:818-855 @ ../node_modules/element-ui/lib/theme-chalk/index.css
     @ ./src/main.js
     @ multi (webpack)-dev-server/client?http://localhost:7777 webpack/hot/dev-server ./src/main.js
    

    解决办法

    修改webpack.config.js文件,在module ules下增加:

    {
        test: /.(eot|svg|ttf|woff|woff2)(?S*)?$/,
        loader: 'file-loader'
    },
    
  • 相关阅读:
    前端 day 05 5.15 JavaScript入门
    前端 day 04 5.14 CSS定位,浮动,JavaScript
    Luogu P1860 新魔法药水
    XJOI 夏令营501-511NOIP训练18 高二学堂
    Luogu P3959 宝藏
    Luogu P2184 贪婪大陆
    XJOI 夏令营501-511NOIP训练18 高三楼
    XJOI 夏令营501-511NOIP训练17 蛇形数阵
    BZOJ 3813 奇数国
    POJ 2728 Desert King
  • 原文地址:https://www.cnblogs.com/fengzzi/p/10882577.html
Copyright © 2011-2022 走看看