1. 程式人生 > 其它 >Vue UI API簡單筆記

Vue UI API簡單筆記

VUE UI

目錄

一 移動端常用UI元件庫

  1. Vant http://vant-contrib.gitee.io/vant/#/zh-CN/
  2. Cube UI https://didi.github.io/cube-ui/
  3. Mint UI http://mint-ui.github.io/#!/zh-cn (vue 2.0)
  4. NUT UI https://nutui.jd.com/#/

二 PC端常用UI元件庫

  1. Element UI https://element.eleme.cn/#/zh-CN
  2. IView UI http://v1.iviewui.com/

三 ElementUI元件按需引入

  1. 首先安裝element-ui:
npm install element-ui
  1. 然後安裝 babel-plugin-component:
npm install babel-plugin-component -D
  1. 修改babel.config.js:
module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
    ["@babel/preset-env", { "modules": false }],
  ],
  plugins: [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}
  1. 在main.js按需引入元件
//引入Vue
import Vue from "vue";
//引入App
import App from './App';

//完整引入
// 引入element-ui元件庫
// import ElementUI from 'element-ui';
/// 引入element全部樣式
// import 'element-ui/lib/theme-chalk/index.css';

// 使用element ui外掛庫
// Vue.use(ElementUI);

//按需引入
import { Button, Input, Row, DatePicker } from 'element-ui';
Vue.use(Button);
Vue.use(Input);
Vue.use(Row);
Vue.use(DatePicker);



//關閉Vue的生產提示
Vue.config.productionTip = false;

new Vue({
    el: '#app',
    render: h => h(App),
});
  1. 然後在App.vue使用
<template>
   <div>
      <button>原生的button</button>
      <input type="text">
      <el-row>
        <el-button>預設按鈕</el-button>
        <el-button type="primary">主要按鈕</el-button>
        <el-button type="success">成功按鈕</el-button>
        <el-button type="info">資訊按鈕</el-button>
        <el-button type="warning">警告按鈕</el-button>
        <el-button type="danger">危險按鈕</el-button>
      </el-row>

     <div class="block">
       <span class="demonstration">預設</span>
       <el-date-picker
           type="date"
           placeholder="選擇日期">
       </el-date-picker>
     </div>
     <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>

<style lang="css" scoped>

</style>