Element-plus側(cè)邊欄踩坑的問(wèn)題解決
問(wèn)題描述
el-menu直接嵌套el-menu-item菜單,折疊時(shí)不會(huì)出現(xiàn)文字顯示和小箭頭無(wú)法隱藏的問(wèn)題,但是實(shí)際開發(fā)需求中難免需要把el-menu-item封裝為組件
解決
vue3項(xiàng)目中嵌套兩層template
<template>
<template v-for="item in list" :key="item.path">
<!-- 一級(jí)路由 -->
<el-menu-item v-if="!item.children && !item.meta?.hidden" :index="item.path">
<el-icon size="30px">
<component :is="item.meta?.icon"></component>
</el-icon>
<template #title>
<span class="ml-1">{{ item.meta?.title }}</span>
</template>
</el-menu-item>
<!-- 二級(jí)路由但只有一個(gè)子項(xiàng) -->
<el-menu-item v-if="(item.meta?.single && item.children) && !item.meta?.hidden" :index="item.children[0].path">
<el-icon size="30px">
<component :is="item.children[0].meta?.icon"></component>
</el-icon>
<template #title>
<span class="ml-1">{{ item.children[0].meta?.title }}</span>
</template>
</el-menu-item>
<!-- 二級(jí)路由 -->
<el-sub-menu :index="item.path" v-if="(item.children && item.children.length > 1) && !item.meta?.hidden">
<template #title>
<el-icon size="30px">
<component :is="item.meta?.icon"></component>
</el-icon>
<span class="ml-1">{{ item.meta?.title }}</span>
</template>
<!-- 遞歸路由 -->
<MenuItem :list="item.children">
</MenuItem>
</el-sub-menu>
</template>
</template>效果

到此這篇關(guān)于Element-plus側(cè)邊欄踩坑的問(wèn)題解決的文章就介紹到這了,更多相關(guān)Element-plus側(cè)邊欄踩坑內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
通過(guò)vue方式實(shí)現(xiàn)二維碼掃碼功能
這篇文章給大家介紹了通過(guò)vue的方式,實(shí)現(xiàn)掃碼功能,實(shí)現(xiàn)步驟分為兩步,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2021-11-11
vue基于element-ui的三級(jí)CheckBox復(fù)選框功能的實(shí)現(xiàn)代碼
最近vue項(xiàng)目需要用到三級(jí)CheckBox復(fù)選框,需要實(shí)現(xiàn)全選反選不確定三種狀態(tài)。這篇文章主要介紹了vue基于element-ui的三級(jí)CheckBox復(fù)選框功能的實(shí)現(xiàn)方法,需要的朋友可以參考下2018-10-10
基于vue+h5實(shí)現(xiàn)車牌號(hào)輸入框功能(demo)
最近開發(fā)項(xiàng)目是學(xué)校校內(nèi)車輛超速方面的統(tǒng)計(jì)檢測(cè)方面的系統(tǒng),在開發(fā)過(guò)程中發(fā)現(xiàn)有個(gè)小功能,就是用戶移動(dòng)端添加車牌號(hào),剛開始想著輸入框,提交時(shí)正則效驗(yàn)一下格式,最后感覺(jué)不方便,所以就簡(jiǎn)單自己手寫了一個(gè)H5車牌號(hào)軟鍵盤,對(duì)vue車牌號(hào)輸入框?qū)崿F(xiàn)代碼感興趣的朋友一起看看吧2025-03-03
關(guān)于el-table表格組件中插槽scope.row的使用方式
這篇文章主要介紹了關(guān)于el-table表格組件中插槽scope.row的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08

