• 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'
    },
    
  • 相关阅读:
    单词 统计
    第十周学习记录
    梦断代码阅读笔记03
    梦断代码阅读笔记02
    梦断代码阅读笔记01
    用户模板和用户场景
    第九周学习记录
    分享好友-分享朋友圈
    生命周期函数-页面刷新
    底部导航的设置
  • 原文地址:https://www.cnblogs.com/fengzzi/p/10882577.html
Copyright © 2020-2023  润新知