Vue UI 组件库

2023-11-09

7.1.常用UI组件库

7.1.1.移动端常用UI组件库

  1. Vant
  2. Cube UI
  3. Mint UI
  4. NutUI

7.1.2.PC端常用UI组件库

  1. Element UI
  2. IView UI

7.2.element-ui基本使用

  1. 安装 element-ui:npm i element-ui -S
  2. src/main.js

    import Vue from 'vue';
    import App from './App.vue';
    
    // 完整引入
    import ElementUI from 'element-ui';             // 引入ElementUI组件库
    import 'element-ui/lib/theme-chalk/index.css';  // 引入ElementUI全部样式
    Vue.use(ElementUI); // 使用ElementUI
    
    Vue.config.productionTip = false;
    
    new Vue({
      el: '#app',
      render: h => h(App)
    })
    
  3. src/App.vue

    <template>
        <div>
            <br/>
            <el-row>
                <el-button icon="el-icon-search" circle></el-button>
                <el-button type="primary" icon="el-icon-edit" circle></el-button>
                <el-button type="success" icon="el-icon-check" circle></el-button>
                <el-button type="info" icon="el-icon-message" circle></el-button>
                <el-button type="warning" icon="el-icon-star-off" circle></el-button>
                <el-button type="danger" icon="el-icon-delete" circle></el-button>
            </el-row>
        </div>
    </template> 
    
    <script>
        export default {
            name:'App'
        }
    </script>
    

在这里插入图片描述

7.3.element-ui按需引入

  1. 安装 babel-plugin-component npm i babel-plugin-component -D
  2. 修改 babel-config-js
    module.exports = {
      presets: [
        '@vue/cli-plugin-babel/preset',
        ["@babel/preset-env", { "modules": false }]
      ],
      plugins: [
          [
            "component",
            { 
              "libraryName": "element-ui",
              "styleLibraryName": "theme-chalk" 
            }
          ]
      ]
    }
    
  3. src/main.js
    import Vue from 'vue';
    import App from './App.vue';
    
    // 完整引入
    // import ElementUI from 'element-ui';             // 引入ElementUI组件库
    // import 'element-ui/lib/theme-chalk/index.css';  // 引入ElementUI全部样式
    // Vue.use(ElementUI); // 使用ElementUI
    
    // 按需引入
    import { Button,Row } from 'element-ui';
    Vue.component(Button.name, Button);
    Vue.component(Row.name, Row);
    
    /** 或写为 
     * Vue.use(Button); 
     * Vue.use(Row);
     */
    
    Vue.config.productionTip = false;
    
    new Vue({
      el: '#app',
      render: h => h(App)
    })
    
    
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Vue UI 组件库 的相关文章

随机推荐