Vue基础27之VueUI组件

文章介绍了Vue中常用的移动端和PC端UI组件库,如Vant、CubeUI、MintUI、ElementUI以及IViewUI。重点讲解了ElementUI的安装、引入以及在main.js和App.vue中的基本使用方法,包括全局引入和按需引入。在按需引入部分,提到了使用babel-plugin-component进行配置,以减少项目体积。
摘要由CSDN通过智能技术生成

Vue UI组件库

移动端常用 UI 组件库

  1. Vant

https://youzan.github.io/vant

  1. Cube UI

https://didi.github.io/cube-ui

  1. Mint UI

http://mint-ui.github.io

PC 端常用 UI 组件库

  1. Element UI

https://element.eleme.cn

  1. IView UI

https://www.iviewui.co

Element-ui插件

基于Vue框架的国产UI组件(饿了么出品)

基本使用

安装

npm i element-ui

在这里插入图片描述

引入并使用
main.js
import Vue from 'vue'

import App from './App'

//引入ElementUI组件库
import ElementUI from 'element-ui'
//引入ElementUI全部样式
import 'element-ui/lib/theme-chalk/index.css';

//关闭vue的生产提示
Vue.config.productionTip = false

//应用ElementUI
Vue.use(ElementUI)
new Vue({
    el: "#app",
    render: h => h(App),
})
App.vue
<template>
  <div class="bg">
    <button>原生按钮</button>
    <input type="text" placeholder="原生input框">
    <br> <br>
<!--    element-ui的引入-->
    <el-button type="primary">主要按钮</el-button>
    <div class="input">
      <el-input  placeholder="请输入内容"></el-input>
    </div>
    <br>
    <el-button icon="el-icon-search" circle></el-button>
    <br>
<!--    日期引入-->
    <el-date-picker
        type="daterange"
        align="right"
        unlink-panels
        range-separator=""
        start-placeholder="开始日期"
        end-placeholder="结束日期"
       >
    </el-date-picker>
  </div>
</template>

<script>
export default {
  name: "App",
}
</script>

<style>
.input{
  width: 200px;
  margin-top: 10px;
}
</style>

在这里插入图片描述

按需引入

安装 babel-plugin-component

npm install babel-plugin-component -D

babel.config.js
module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
    ["@babel/preset-env", { "modules": false }]
  ],
  plugins: [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

main.js
import Vue from 'vue'

import App from './App'

// //引入ElementUI组件库
// import ElementUI from 'element-ui'
// //引入ElementUI全部样式
// import 'element-ui/lib/theme-chalk/index.css';

//关闭vue的生产提示
Vue.config.productionTip = false

//按需引入
import{Button,Row,DatePicker,Input} from "element-ui";

// //应用ElementUI
// Vue.use(ElementUI)
Vue.component(Button.name,Button)
Vue.component(Row.name,Row)
Vue.component(Input.name,Input)
Vue.component('expecial-datePicker',DatePicker)

new Vue({
    el: "#app",
    render: h => h(App),
})
App.vue
<template>
  <div class="bg">
    <button>原生按钮</button>
    <input type="text" placeholder="原生input框">
    <br> <br>
<!--    element-ui的引入-->
    <el-row>
      <el-button type="primary">主要按钮</el-button>
    </el-row>
    <div class="input">
      <el-input  placeholder="请输入内容"></el-input>
    </div>
    <el-row>
      <el-button icon="el-icon-search" circle></el-button>
    </el-row>
<!--    日期引入-->
    <expecial-datePicker
        type="daterange"
        align="right"
        unlink-panels
        range-separator=""
        start-placeholder="开始日期"
        end-placeholder="结束日期"
       >
    </expecial-datePicker>
  </div>
</template>

<script>
export default {
  name: "App",
}
</script>

<style>
.input{
  width: 200px;
  margin-top: 10px;
}
</style>



在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值