zoukankan      html  css  js  c++  java
  • ant-desing-vuex系列1--集合@vue/cli4简单使用

    1、安装@vue/cli4

    npm install -g @vue/cli
    

    2、vue create之后安装ant-design-vue

    npm i ant-design-vue --save
    

    3、配置按需加载

    npm i babel-plugin-import --save-dev
    

    4、修改根目录的 babel.config.js, 配置 babel-plugin-import

    module.exports = {
      presets: [
        '@vue/cli-plugin-babel/preset'
      ],
      plugins: [
        [
          "import",
          { libraryName: "ant-design-vue", libraryDirectory: "es", style: true }
        ]
      ]
    }
    

    4、配置less

    运行报错Module not found: Error: Can't resolve 'less-loader'

    npm i less less-loader --save-dev
    

    5、根目录创建 vue.config.js 文件,配置如下

    module.exports = {
        css: {
            loaderOptions: {
                less: {
                    javascriptEnabled: true
                }
            }
        }
    }
    

    6、项目中引用

    src/main.js 文件中
      import Vue from 'vue'
      import { Button, Select } from 'ant-design-vue';
      import App from './App'
     
      Vue.component(Button.name, Button)
      Vue.component(Select.name, Select)
     
    /* 或写为
     * Vue.use(Button)
     * Vue.use(Select)
     */
     
      Vue.config.productionTip = false
     
      new Vue({
        render: h => h(App)
      }).$mount("#app");<br><br><br>组件中就可以使用:<br><a-button type="primary">winyh</a-butto
    
  • 相关阅读:
    三种省市级联下拉列表的写法
    三种省市级联下拉列表的写法
    SQL经典试题(mysql)
    60行代码俄罗斯方块
    ibatis xml中配置信息详解
    60行代码俄罗斯方块
    xinetd
    csh and tcsh
    xinetd restart
    bash sh
  • 原文地址:https://www.cnblogs.com/xidianzxm/p/12305591.html
Copyright © 2011-2022 走看看