【Vue】Vue2使用ElementUI

目錄

  • Element UI
    • 介紹
    • 特點
    • Vue2使用Element
      • 安裝
      • 引入ElementUI組件庫
    • 使用ElementUI
      • 用戶注冊
      • 列表展示
      • 其他
  • mint-ui
    • 介紹
    • 特點
    • 安裝組件
    • 引入組件
    • Mint-ui相關組件

Element UI

介紹

  • 官網(基于 Vue 2.x ):https://element.eleme.cn/#/zh-CN

  • ElementUI 是一個基于 Vue.js 的桌面端組件庫,由餓了么前端團隊開發并維護。它提供了一套豐富的 UI 組件和布局,以及一些常用的功能組件,讓開發者可以快速搭建美觀、可用的 Web 應用。

  • ElementUI 的組件庫包括按鈕、表單、輸入框、下拉菜單、表格、彈窗等等,它們都具有一致的樣式和交互效果,可以方便地進行組合和定制。ElementUI 還提供了一些常用的功能組件,如日期選擇器、分頁器、消息提示等,這些組件可以大大簡化開發過程,提高效率。

  • ElementUI 的設計風格簡潔大方,符合現代化的 UI 設計規范。它使用了靈活的柵格系統來布局頁面,可以適應不同尺寸的屏幕。同時,ElementUI 支持多語言和主題定制,開發者可以根據自己的需求進行配置。

  • ElementUI 提供了詳細的文檔和示例代碼,可以幫助開發者快速上手并解決問題。此外,ElementUI 還有一個活躍的社區,開發者可以在社區中分享經驗、提問問題,并獲取幫助。

  • ElementUI 是一個功能強大、易于使用的前端組件庫,適用于快速構建漂亮且可用的 Web 應用。無論是個人項目還是企業級應用,ElementUI 都能提供良好的支持,讓開發變得更加高效和愉快。
    在這里插入圖片描述

特點

ElementUI 的特點有以下幾個:

  1. 簡潔美觀:ElementUI 的設計風格簡潔大方,符合現代化的 UI 設計規范。它提供了一致的樣式和交互效果,使得應用看起來非常美觀,并且可以適應不同尺寸的屏幕。

  2. 豐富的組件:ElementUI 提供了一套豐富的 UI 組件,包括按鈕、表單、輸入框、下拉菜單、表格、彈窗等等。這些組件具有靈活的用法和豐富的功能,可以滿足各種需求。

  3. 響應式布局:ElementUI 使用了靈活的柵格系統來布局頁面,可以適應不同尺寸的屏幕。它支持響應式布局,使得應用在不同設備上都能有良好的展示效果。

  4. 高度可定制:ElementUI 支持多語言和主題定制,開發者可以根據自己的需求進行配置。它提供了豐富的主題和樣式變量,可以方便地定制組件的外觀和樣式。

  5. 完善的文檔和示例:ElementUI 提供了詳細的文檔和示例代碼,開發者可以通過閱讀文檔和參考示例來快速上手和解決問題。它還有一個活躍的社區,開發者可以在社區中分享經驗、提問問題,并獲取幫助。
    在這里插入圖片描述

Vue2使用Element

安裝

npm下載ElementUI:npm install element-ui@2.15.3或者npm i element-ui -S

引入ElementUI組件庫

在main.js中內容:

import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
//樣式文件需要單獨引入
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
Vue.config.productionTip = falsenew Vue({render: h => h(App),
}).$mount('#app')

使用ElementUI

其實在官網有很多很多案例,這里我準備了一個用戶注冊的form表單案例,和一個表格展示案例

用戶注冊

<template><div><el-form :model="user" status-icon :rules="rules" ref="user" label-width="100px" class="demo-user"><el-form-item label="賬號" prop="userCode"><el-input type="text" v-model="user.userCode" autocomplete="off"></el-input></el-form-item><el-form-item label="姓名" prop="userName"><el-input type="text" v-model="user.userName" autocomplete="off"></el-input></el-form-item><el-form-item label="密碼" prop="userPassword"><el-input type="userPassword" v-model="user.userPassword" autocomplete="off"></el-input></el-form-item><el-form-item label="確認密碼" prop="checkPass"><el-input type="password" v-model="user.checkPass" autocomplete="off"></el-input></el-form-item><el-form-item label="性別" prop=""><el-radio-group v-model="user.gender"><el-radio-button label="0" ></el-radio-button><el-radio-button label="1" ></el-radio-button></el-radio-group></el-form-item><el-form-item label="出生年月" prop="birthday"><el-date-pickerv-model="user.birthday"align="right"type="date"placeholder="選擇日期":picker-options="pickerOptions"></el-date-picker></el-form-item><el-form-item label="地址" prop="address"><el-input type="text" v-model="user.address" autocomplete="off"></el-input></el-form-item><el-form-item label="手機號" prop="phone"><el-input type="text" v-model="user.phone" autocomplete="off"></el-input></el-form-item><el-form-item label="角色" prop="userRole"><el-select v-model="user.userRole" placeholder="請選擇"><el-optionv-for="item in roleList":key="item.value":label="item.name":value="item.value":disabled="item.disabled"></el-option></el-select></el-form-item><el-form-item label="興趣愛好" prop="hobbys"><el-checkbox-groupv-model="user.hobbys"max="3"><el-checkbox v-for="hobby in hobbys" :label="hobby" :key="hobby">{{hobby}}</el-checkbox></el-checkbox-group></el-form-item><el-form-item><el-button type="primary" @click="submitForm('user')">提交</el-button><el-button @click="resetForm('user')">重置</el-button></el-form-item></el-form></div>
</template>
<script>
export default {// eslint-disable-next-line vue/multi-word-component-namesname:'Register',data() {//自定義校驗規則var validatePass2 = (rule, value, callback) => {if (value === '') {callback(new Error('請再次輸入密碼'));} else if (value !== this.user.userPassword) {callback(new Error('兩次輸入密碼不一致!'));} else {callback();}};return {hobbys:["唱","跳","RAP","打籃球"],roleList:[{name:'系統管理員',value:1},{name:'管理員',value:2},{name:'會員',value:3},{name:'游客',value:4}],//表單數據綁定user:{userCode:'',userName:'',userPassword:'',gender:0,birthday:'',phone:'',address:'',userRole:4,hobbys:[],checkPass:''},//定義表單基本的驗證rules: {userCode: [{ required:true,trigger: 'blur', message: '請輸入賬號',  }],userName: [{ required:true,trigger: 'blur', message: '請輸入用戶名',  }],userPassword: [{ required:true,trigger: 'blur', message: '請輸入密碼',  }],checkPass: [{ validator: validatePass2, trigger: 'blur' }],},//日期插件設置pickerOptions: {disabledDate(time) {return time.getTime() > Date.now();},shortcuts: [{text: '今天',onClick(picker) {picker.$emit('pick', new Date());}}, {text: '昨天',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24);picker.$emit('pick', date);}}, {text: '一周前',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);picker.$emit('pick', date);}}]},};},methods: {submitForm(formName) {this.$refs[formName].validate((valid) => {if (valid) {alert('submit!');} else {console.log('error submit!!');return false;}});},resetForm(formName) {this.$refs[formName].resetFields();}}
}
</script>

列表展示

<template><div><el-table:data="userList"stripestyle="width: 100%"><el-table-columnprop="id"label="ID"style="width: 15%"></el-table-column><el-table-columnprop="userCode"label="賬號"style="width: 15%"></el-table-column><el-table-columnprop="userName"label="姓名"style="width: 15%"></el-table-column><el-table-columnprop="gender"label="性別"style="width: 6%"></el-table-column><el-table-columnprop="birthday"label="出生年月"style="width: 15%"></el-table-column><el-table-columnprop="phone"label="聯系方式"style="width: 15%"></el-table-column><el-table-columnprop="address"label="地址"style="width: 15%"></el-table-column><el-table-columnprop="userRole"label="角色"></el-table-column><el-table-column label="操作"><template slot-scope="scope"><el-buttonsize="mini"@click="handleEdit(scope.$index, scope.row)">編輯</el-button><el-buttonsize="mini"type="danger"@click="handleDelete(scope.$index, scope.row)">刪除</el-button></template></el-table-column></el-table></div>
</template>
<script>
export default {// eslint-disable-next-line vue/multi-word-component-namesname:'Register',data() {return{userList:[{id:1,userCode:'admin',userName:'系統管理員',gender:'男',birthday:'1993-11-12',phone:'13865427845',address:'北京市',userRole:'系統管理員'},{id:2,userCode:'sunshangxiang',userName:'孫尚香',gender:'女',birthday:'1999-12-17',phone:'13965489527',address:'鄭州市',userRole:'游客'},{id:3,userCode:'guanyu',userName:'關羽',gender:'男',birthday:'2000-01-09',phone:'15765842469',address:'徐州市',userRole:'會員'},{id:4,userCode:'sunquan',userName:'孫權',gender:'男',birthday:'1992-10-08',phone:'18965552451',address:'杭州市',userRole:'管理員'},{id:5,userCode:'liubei',userName:'劉備',gender:'男',birthday:'1989-09-24',phone:'15068689595',address:'廣州市',userRole:'管理員'},{id:6,userCode:'caocao',userName:'曹操',gender:'男',birthday:'1992-10-08',phone:'15545211245',address:'兗州市',userRole:'管理員'},{id:7,userCode:'huangyueying',userName:'黃月英',gender:'女',birthday:'2009-01-01',phone:'15966648531',address:'亳州市',userRole:'游客'},]}},methods: {}
}
</script>

在這里插入圖片描述

其他

詳見官網…

mint-ui

介紹

  • Mint UI是一個基于Vue.js的移動端組件庫,由餓了么前端團隊開發。
  • 它提供了一系列豐富的UI組件,包括按鈕、輸入框、彈窗、輪播圖、下拉刷新等常用組件,可以幫助開發者快速構建移動端的Web應用。
  • Mint UI具有簡單易用、效果好、樣式漂亮等特點,受到了廣大開發者的歡迎。
  • Mint UI官網: http://mint-ui.github.io/#!/zh-cn

特點

Mint UI具有以下特點:

  1. 簡單易用:Mint UI提供了豐富的移動端UI組件,使用簡單,開發者可以快速上手,并快速構建移動端應用。

  2. 輕量化:Mint UI的組件庫比較輕量,可以高效地加載和運行在移動設備上,提供了更好的用戶體驗。

  3. 樣式漂亮:Mint UI的組件擁有精美的視覺效果,具有現代化、時尚的外觀,能夠滿足用戶對于UI設計的要求。

  4. 功能豐富:Mint UI提供了豐富的組件,包括按鈕、輸入框、彈窗、輪播圖、下拉刷新等常見的移動端UI組件,滿足開發者在移動應用開發中的各種需求。

  5. 支持Vue.js:Mint UI是基于Vue.js開發的組件庫,與Vue.js完美融合,開發者可以使用Vue.js的特性和功能來更加靈活地定制和使用組件。

總之,Mint UI具有簡單易用、輕量化、樣式漂亮、功能豐富等特點,適用于開發移動端的Web應用。Mint UI具有以下特點:

在這里插入圖片描述

安裝組件

npm install mint-ui -S

引入組件

  • 引入全部組件

    // 引入全部組件 import Vue from 'vue'; import Mint from 'mint-ui'; 
    Vue.use(Mint);
    
  • 按需引入

  • 借助 babel-plugin-component,我們可以只引入需要的組件,以達到減小項目體積的目的。

  • 首先,安裝 babel-plugin-component: npm install babel-plugin-component -D

    {"presets": [["es2015", { "modules": false }]],"plugins": [["component", [{"libraryName": "mint-ui","style": true}]]]
    }
    
  • 如果你只希望引入部分組件,比如 Button 和 Cell,那么需要在 main.js 中寫入以下內容:需要引入樣式:import 'mint-ui/lib/style.css';

    // The Vue build version to load with the `import` command
    // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
    import Vue from 'vue'
    import App from './App'
    import router from './router'// 1、引入Element-ui組件
    // import { Button } from 'element-ui';
    // Vue.use(Button)// 2、引入Mint-ui組件
    import 'mint-ui/lib/style.css';
    import {Button} from 'mint-ui';
    Vue.component(Button.name, Button);Vue.config.productionTip = false  //設置在控制臺環境進行代碼提示作用// 1.全局路由守衛
    router.beforeEach((to,from,next) => {/*to:表示要去的新頁面from:表示舊的頁面next:表示是否*/// 0——表示未登錄// 1——表示已登錄var islogin = 1;if(to.meta.needAuth){if(islogin == 0){router.push({name:'login'})}if(islogin == 1){next()}}else{next()}
    })// 2.全局過濾器
    Vue.filter('toFixed1',function(val,data,data1){return data1 + val.toFixed(data)
    })/* eslint-disable no-new */
    new Vue({el: '#app',router,components: { App },template: '<App/>'
    })
    

Mint-ui相關組件

官網文檔: https://mint-ui.github.io/docs/#/zh-cn2
在這里插入圖片描述

<template><div class="hello"><mt-button type="danger" @click="myToast">danger</mt-button><hr><el-button type="primary">主要按鈕</el-button><hr><router-link to="/mydetail">產品詳情</router-link><router-link to="/mycar">購物車</router-link><router-link to="/myorder">下單頁面</router-link><hr><button @click="mytab">點擊</button><hr/><router-link to="/tab">選項卡</router-link><hr/><myslot><div slot="name1">{{msg}}</div><div slot="name2">{{num}}</div></myslot><hr/><input type="text" placeholder="請輸入用戶名" v-model="t1"/><input type="text" placeholder="請輸入密碼" v-model="t2"/><button :class="{active:isTrue}">登錄</button><hr/><input type="text" name="" id="" v-model="num3"/><hr/><input type="text" placeholder="請輸入用戶名" v-model="user"/><input type="text" placeholder="請輸入密碼" v-model="password"/><button :class="{active:getActive}">登錄</button><h1>{{getAvg}}</h1><h1>{{getSum}}</h1><h1>{{num | toFixed(5,"$")}}</h1><h1>{{num1 | toFixed1(5,"$")}}</h1><h1>{{msg}}</h1></div>
</template><script>
import { Toast } from 'mint-ui';
import myslot from './02slot';export default {name: 'HelloWorld',data () {return {num:10,num1:20,num3:100,msg: 'Welcome to Your Vue.js App',user:'',password:'',isTrue:false,t1:'',t2:'',}},filters:{toFixed(val,data,data1){return data1 + val.toFixed(data)}},computed:{getSum(){return this.num + this.num1;},getAvg(){return this.getSum/2;},getActive(){if(this.user==''||this.password==''){return false}return true}},watch:{num3(){console.log("num3修改了")},t1(){if(this.t1 == '' || this.t2 ==''){this.isTrue = false}else{this.isTrue = true}},t2(){if(this.t1 == '' || this.t2 ==''){this.isTrue = false}else{this.isTrue = true}}},components:{myslot,},methods:{mytab(){//鏈式路由跳轉this.$router.push({// 方式一// name:'tab'// 方式二path:'/tab',query:{id:100}})},myToast(){Toast({message: '提示',position: 'center',duration: 5000});}},
}
</script><!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>.active{color: red;}h1, h2 {font-weight: normal;}ul {list-style-type: none;padding: 0;}li {display: inline-block;margin: 0 10px;}a {color: #42b983;}
</style>

前端第三方組件庫國內官網地址

Vant-ui 國內官網: https://vant-contrib.gitee.io/vant/#/zh-CN/
layui 官網: https://layuion.com/docs/element/color.html
jQuery 官網:https://www.jquery123.com/
Apache ECharts 官網:https://echarts.apache.org/zh/index.html

微信開發文檔官網:https://developers.weixin.qq.com/miniprogram/dev/framework/

w3c國內官網:https://www.w3school.com.cn/

mdn國內官網:https://developer.mozilla.org/zh-CN/docs/Web/HTML

swiper官網 :https://www.swiper.com.cn/usage/index.html

betterscroll官網:添加鏈接描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/14366.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/14366.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/14366.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Vue文本溢出如何自動換行

css新增 word-break: break-all; word-wrap: break-word;

【Linux系統】文件與基礎IO

本篇博客整理了文件與文件系統、文件與IO的相關知識&#xff0c;借由庫函數、系統調用、硬件之間的交互、操作系統管理文件的手段等&#xff0c;旨在讓讀者更深刻地理解“Linux下一切皆文件”。 【Tips】文件的基本認識 文件 內容 屬性。文件在創建時就有基本屬性&#xff0…

網易:一季度營收269億元,連續7季研發強度超15%領跑行業

5月23日&#xff0c;網易發布2024年第一季度財報。財報顯示&#xff0c;網易Q1營收269億元&#xff0c;歸屬于公司股東的凈利潤85億元&#xff08;Non-GAAP&#xff09;&#xff0c;以連續7個季度超15%的研發投入強度領跑行業&#xff0c;首季業績穩健啟航。 一季度&#xff0…

JVM學習-動態鏈接和方法返回地址

動態鏈接–指向運行時常量池的方法引用 每一個棧幀內部包含一個指向運行時常量池中該棧幀所屬方法的引用&#xff0c;包含這個引用的目的為了支持當前方法的代碼能夠實現動態鏈接(Dynamic Linking)&#xff0c;如invokednamic指令。在Java源文件被編譯到字節碼文件中時&#x…

云平臺概要設計文檔 -大綱

1. 引言 1.1 目的 本文檔的目的是提供一份詳細的技術規范,用以指導開發團隊實現云平臺的建設和部署。該文檔旨在確保所有開發人員和相關技術人員對系統的架構、組件、交互流程、數據處理及安全措施有深入的理解,從而能夠高效、一致地開發出符合預期功能和性能要求的系統。 …

JAVA:淺談JSON與JSON轉換

可能有很多人&#xff0c;無論是前端還是后端&#xff0c;無論是JAVA還是Python還是C&#xff0c;都應該跟JSON這種數據格式打過交道&#xff0c;那么有沒有仔細的想過&#xff0c;什么叫JSON&#xff1f; JSON是一種輕量級的數據交換格式。它基于JavaScript語言的對象表示法&a…

初識java——javaSE(6)抽象類與接口【求個關注!】

文章目錄 前言一 抽象類1.1 抽象類的概念1.2 抽象類的語法&#xff1a;1.3 抽象類與普通類的區別&#xff1a; 二 接口2.1 接口的概念2.2 接口的語法2.2.1 接口的各個組成2.2.2 接口之間的繼承 2.3 接口的實現接口不可以實例化對象 2.4 接口實現多態 三 Object類3.1 Object類是…

【shell】腳本練習題

案例&#xff1a; 1. for ping測試指網段的主機 網段由用戶輸入&#xff0c;例如用戶輸入192.168.2 &#xff0c;則ping 192.168.2.10 --- 192.168.2.20 UP&#xff1a; /tmp/host_up.txt Down: /tmp/host_down.txt 2. 使用case實現成績優良差的判斷 1. for ping測試指…

Android異常及解決方式記錄

異常1&#xff1a;Tmp detached view should be removed from RecyclerView before it can be recycled: 解決方法&#xff1a; recycleView.setItemAnimator(null);

第17講:C語言內存函數

目錄 1.memcpy使用和模擬實現2.memmove使用和模擬實現3.memset函數的使用4.memcmp函數的使用 1.memcpy使用和模擬實現 void * memcpy (void * destination, const void * source, size_t num);? 函數memcpy從source的位置開始向后復制num個字節的數據到destination指向的內存…

Python面試寶典:Python中與多線程編程相關的面試筆試題(1000加面試筆試題助你輕松捕獲大廠Offer)

Python面試寶典:1000加python面試題助你輕松捕獲大廠Offer【第二部分:Python高級特性:第十三章:并發編程:第一節:多線程編程】 第十三章:并發編程第一節:多線程編程使用`threading`模塊面試題1面試題2面試題3面試題4面試題5面試題6面試題7面試題8面試題9面試題10更多面…

打豆豆game

好的&#xff0c;我將為您編寫一個簡單的“打豆豆”游戲。這個游戲的基本規則是這樣的&#xff1a; 游戲將生成一個指定大小的網格&#xff0c;每個格子可能包含一個豆豆。玩家可以指定一個格子&#xff0c;如果該格子中有豆豆&#xff0c;則打掉該豆豆&#xff0c;并得分。每…

【Java 開發】模版模式使用模版

在日常開發中&#xff0c;對適合的場景。使用模板模式可以幫助我們抽取公共的東西&#xff0c;使代碼更加優雅。本次寫了一個模版模式的使用模版&#xff0c;方便以后 cv。 本次是以訂單的接受、拒絕、關閉三個操作作為 demo 來寫的模板。 一、定義請求基類&#xff0c;不同操作…

leecode42 DP

自己的暴力想法,把圖形看成一個個碗,一段一段地算,錯誤示例 class Solution { public:int trap(vector<int>& height) {int s height.size();int sum 0,kk1;int flag 0;int p1 -1, p2 -1;for (int i 1; i < s; i) {cout<<p1<<endl;if (p1 >…

網絡安全技術與應用:遠程控制與數據庫安全

實驗準備 軟件&#xff1a;VMware Workstation Pro 虛擬機&#xff1a;Red Hat Enterprise Linux 7 服務器&#xff0c;Red Hat Enterprise Linux 7 客戶端 網絡模式&#xff1a;NAT模式 1、配置服務器及客戶端網絡 服務器IP 客戶端IP 測試相互通信 在客戶機上設置鏡像&#…

【C++刷題】優選算法——遞歸第二輯

全排列 vector<vector<int>> vv; void dfs(vector<int>& nums, vector<int>& v, vector<bool>& check) {if(v.size() nums.size()){vv.push_back(v);return;}for(int i 0; i < nums.size(); i){if(check[i] false){v.push_ba…

pillow學習5

ImageEnhance 模塊 內置的 ImageEnhance 模塊中包含了多個用于增強圖像效果的函數&#xff0c;主要用來調整圖像 的色彩、對比度、亮度和清晰度等&#xff0c;感覺上和調整電視機的顯示參數一樣。 在模塊 ImageEnhance 中&#xff0c;所有的圖片增強對象都實現一個通用的接口。…

nginx的配置以及常見命令

Nginx配置與常用命令指南 Nginx是一個高性能的HTTP和反向代理服務器&#xff0c;也是一個IMAP/POP3/SMTP服務器。由于它的穩定性、豐富的功能集、簡單的配置文件和低資源消耗&#xff0c;Nginx在全球范圍內被廣泛使用。在本文中&#xff0c;我們將介紹Nginx的基本配置和一些常…

車載網絡測試實操源碼_使用CAPL腳本模擬發送符合協議要求(Counter和CRC)的CAN報文

系列文章目錄 車載網絡測試實操源碼_使用CAPL腳本解析hex、S19、vbf文件 車載網絡測試實操源碼_使用CAPL腳本對CAN報文的Counter和CRC進行實時監控 車載網絡測試實操源碼_使用CAPL腳本模擬發送符合協議要求(Counter和CRC)的CAN報文 車載網絡測試實操源碼_使用CAPL腳本實現安全…

利用神經網絡學習語言(四)——深度循環神經網絡

相關說明 這篇文章的大部分內容參考自我的新書《解構大語言模型&#xff1a;從線性回歸到通用人工智能》&#xff0c;歡迎有興趣的讀者多多支持。 本文涉及到的代碼鏈接如下&#xff1a;regression2chatgpt/ch10_rnn/char_rnn_batch.ipynb 《循環神經網絡&#xff08;RNN&…