vue3 element-plus如何使用icon圖標(biāo)組件
更新時間:2024年03月19日 14:15:22 作者:天馬3798
這篇文章主要介紹了vue3 element-plus如何使用icon圖標(biāo)組件問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
vue3 element-plus使用icon圖標(biāo)組件
目前 element-plus版本是2.0.4
當(dāng)前版本的icon還沒有默認(rèn)在組件中,需要另外安裝才能使用圖標(biāo)。
使用步驟
1.安裝@element-plus/icons-vue庫
npm install @element-plus/icons-vue
2.全局引入icon組件
import { createApp } from 'vue' import App from './App.vue' import installElementPlus from './plugins/element' //main.js import * as ElIconModules from '@element-plus/icons-vue' var app=createApp(App); app.use(installElementPlus); Object.keys(ElIconModules).forEach(function (key) { app.component(ElIconModules[key].name, ElIconModules[key]) }) app.mount('#app');
3.使用icon
<edit style="width: 1em; height: 1em; margin-right: 8px;" /> <share style="width: 1em; height: 1em; margin-right: 8px;" /> <delete style="width: 1em; height: 1em; margin-right: 8px;" /> <search style="width: 1em; height: 1em; margin-right: 8px;" />
<el-button type="primary"> <el-icon style="vertical-align: middle;"> <search /> </el-icon> <span style="vertical-align: middle;"> Search </span> </el-button>
之前的使用方式還在支持中,目前需要特殊導(dǎo)入。
<template> <div class="flex"> <el-button type="primary" :icon="Edit"></el-button> <el-button type="primary" :icon="Share"></el-button> <el-button type="primary" :icon="Delete"></el-button> <el-button type="primary" :icon="Search">Search</el-button> <el-button type="primary"> Upload<el-icon class="el-icon--right"><Upload /></el-icon> </el-button> </div> </template> <script setup lang="ts"> import { Edit, Share, Delete, Search, Upload } from '@element-plus/icons-vue' </script>
4.動態(tài)綁定icon/菜單動態(tài)綁定icon
// html <template> <component class="xxx" :is="iconName"></component> </template>
// script export default { name: 'Login', setup() { const iconName = 'Search' return { iconName } } }
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
解決vue使用vant輪播組件swipe + flex時文字抖動問題
這篇文章主要介紹了解決vue使用vant輪播組件swipe + flex時文字抖動問題,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2021-01-01vue中$set的使用(結(jié)合在實際應(yīng)用中遇到的坑)
這篇文章主要介紹了vue中$set的使用(結(jié)合在實際應(yīng)用中遇到的坑),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-07-07vue組件表單數(shù)據(jù)回顯驗證及提交的實例代碼
今天小編就為大家分享一篇vue組件表單數(shù)據(jù)回顯驗證及提交的實例代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08vue element 生成無線級左側(cè)菜單的實現(xiàn)代碼
這篇文章主要介紹了vue element 生成無線級左側(cè)菜單的實現(xiàn)代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-08-08vue中使用element組件時事件想要傳遞其他參數(shù)的問題
這篇文章主要介紹了vue中使用element組件時事件想要傳遞其他參數(shù)的問題,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-09-09使用Mockjs模擬接口實現(xiàn)增刪改查、分頁及多條件查詢
Mock.js是一個模擬數(shù)據(jù)生成器,可以讓前端獨立于后端進(jìn)行開發(fā),下面這篇文章主要給大家介紹了關(guān)于使用Mockjs模擬接口實現(xiàn)增刪改查、分頁及多條件查詢的相關(guān)資料,需要的朋友可以參考下2022-04-04