zoukankan      html  css  js  c++  java
  • vue——按需引入elementUI(以时间选择器为例)

    参考:https://www.jianshu.com/p/40da0ba35ac1

    1.  安装

    npm install babel-plugin-component –D

    2.  修改.babelrc

    原babelrc:

    {
      "presets": [
        ["env", {
          "modules": false,
          "targets": {
            "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
          }
        }],
        "stage-2"
      ],
      "plugins": ["transform-vue-jsx", "transform-runtime",]
    }

    修改后:

    {
      "presets": [
        ["env", {
          "modules": false,
          "targets": {
            "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
          }
        }],
        "stage-2"
      ],
      "plugins": ["transform-vue-jsx", "transform-runtime",
        ["component",{      // <==     "libraryName":"element-ui",// <==     "styleLibraryName":"theme-chalk" // <==     }
        ]
      ] }

    3.  按需引入组件

    main.js:

    import Vue from 'vue';
    import App from './App';
    import { DatePicker } from 'element-ui';
    
    Vue.use(DatePicker);

    需要用到elementUI的组件:

    <style scoped>
      @import 'https://unpkg.com/element-ui@2.3.7/lib/theme-chalk/index.css';
    </style>
  • 相关阅读:
    动画差值
    高达模型
    TCP/IP负载均衡
    FreeImage使用
    Game Programming Pattern
    Apple Instruments
    GLEW OpenGL Access violation when using glGenVertexArrays
    微服务了解
    summary
    事务传播行为
  • 原文地址:https://www.cnblogs.com/linjiangxian/p/12190809.html
Copyright © 2011-2022 走看看