zoukankan      html  css  js  c++  java
  • 在vue2.0中引用element-ui组件库

    element-ui是由饿了么团队开发的一套基于 Vue 2.0 的桌面端组件库。

    官网:http://element.eleme.io/

    安装

    npm i element-ui -S

    引用完整的element-ui

    import ElementUI from 'element-ui';
    import 'element-ui/lib/theme-chalk/index.css';
    
    Vue.use(ElementUI);

    需要注意的是,样式文件需要单独引入。

    如果报错,在 webpack.config.js 中配置 file_loader。可以在 rules 数组内直接增加下面这个配置项:

    {
        test: /.(eot|svg|ttf|woff|woff2)(?S*)?$/,
        loader: 'file-loader'
    }

    按需引入组件

    1、安装 babel-plugin-component 插件:

    npm install babel-plugin-component -D 

    2、修改 .babelrc 配置文件

    {
        "presets": [
            ["env", { "modules": false }],
            "stage-3"
        ]
    }

    改为:

    {
      "presets": [["env", { "modules": false }]],
      "plugins": [
        [
          "component",
          {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
          }
        ]
      ]
    }

    3、如果报错,在 webpack.config.js 中配置 file_loader。

    可以在 rules 数组内直接增加下面这个配置项:

    {
        test: /.(eot|svg|ttf|woff|woff2)(?S*)?$/,
        loader: 'file-loader'
    }

    4、使用组件

    import { Button, Select } from 'element-ui';
    
    Vue.component(Button.name, Button);
    Vue.component(Select.name, Select);
    /* 或写为
     * Vue.use(Button)
     * Vue.use(Select)
     */
  • 相关阅读:
    concrete maths ch4 number theory
    Aho-Corasick algorithm
    Finding repetitions
    Suffix Automaton
    Z-function and its calculation
    mongodb安装与启动
    centos redis 集群搭建
    nginx实现热部署(平滑升级)
    nacos集群部署安装
    springboot+zookeeper+dubbo整合
  • 原文地址:https://www.cnblogs.com/jofun/p/9208344.html
Copyright © 2011-2022 走看看