vue側(cè)邊欄動(dòng)態(tài)生成下級(jí)菜單的方法
循環(huán)傳入的數(shù)據(jù)去生成下級(jí)菜單
<template>
<div class="headBar">
<div class="title">
微商城管理后臺(tái)
</div>
<el-menu
class="el-menu-headBar"
mode="horizontal"
@select="handleSelect"
background-color="#000000"
text-color="#fff"
active-text-color="#ffd04b"
:unique-opened="true"
:default-active="onRoutes" router>
<template v-for="item in items" >
<template v-if="item.subs" >
<el-submenu :index="item.index">
<template slot="title" >
{{item.title}}
</template>
<el-menu-item v-for="(subItem,i) in item.subs" :key="i" :index="subItem.index">
{{ subItem.title }}
</el-menu-item>
</el-submenu>
</template>
<template v-else>
<el-menu-item :index="item.index">
<label>{{ item.title }}</label>
</el-menu-item>
</template>
</template>
</el-menu>
</div>
</template>
<script>
export default {
data() {
return {
activeIndex: "1",
items: [
{
icon: 'el-icon-menu',
index: '1',
title: '數(shù)據(jù)統(tǒng)計(jì)',
subs: [
{
index: '/monitor',
title: '客流展示'
},
{
index: '/monitor/device',
title: '設(shè)備采集'
},
{
index: '/monitor/tv',
title: '監(jiān)控視頻'
}
]
},{
icon: 'el-icon-goods',
index: '/product',
title: '商品管理',
},{
icon: 'el-icon-goods',
index: '/category',
title: '類目管理',
},{
icon: 'fa fa-cart-arrow-down',
index: '/order',
title: '訂單一覽'
},{
icon: 'fa fa-user-o',
index: '/merchant',
title: '商家信息'
},{
icon: 'el-icon-printer',
index: '9',
title: '微商城',
subs:[
{
icon: 'el-icon-printer',
index: '/banner',
title: 'banner設(shè)置'
},{
icon: 'el-icon-printer',
index: '/decoration',
title: '首頁裝修'
},{
icon: 'el-icon-printer',
index: '/message',
title: '消息設(shè)置'
}
]
},{
icon: 'el-icon-printer',
index: '10',
title: '線下店',
subs:[
{
icon: 'el-icon-printer',
index: '/device',
title: '設(shè)備管理'
},{
icon: 'el-icon-printer',
index: '/advertise',
title: '廣告管理'
},{
icon: 'el-icon-printer',
index: '/version',
title: '版本管理'
}
]
},{
icon: 'el-icon-printer',
index: '/largeUI',
title: '大屏'
},{
icon: 'el-icon-printer',
index: '/coupon',
title: '優(yōu)惠券'
}
],
}
},
methods: {
handleSelect(key, keyPath) {
console.log(key, keyPath);
}
},
computed:{
onRoutes(){
return this.$route.path.replace('/','');
}
}
}
</script>
<style scoped>
.el-menu-headBar {
width: 80%;
min-width: 950px;
font-size: 12px;
border-bottom: 1px #000000;
}
.headBar {
width: 100%;
height: 50px;
display: flex;
background-color: #000000;
}
.title {
background-color: #ffdb15;
color: #000;
height: 100%;
min-width: 200px;
width: 200px;
display: flex;
justify-content: center;
align-items: center;
letter-spacing: 5px;
font-size: 17px;
}
</style>
以上這篇vue側(cè)邊欄動(dòng)態(tài)生成下級(jí)菜單的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue與django集成打包的實(shí)現(xiàn)方法
這篇文章主要介紹了vue與django集成打包的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11
解決vue?eslint開發(fā)嚴(yán)格模式警告錯(cuò)誤的問題
這篇文章主要介紹了解決vue?eslint開發(fā)嚴(yán)格模式警告錯(cuò)誤的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04
vue3+vite2中使用svg的方法詳解(親測(cè)可用)
vue2的時(shí)候使用的是字體圖標(biāo),缺點(diǎn)就是比較單一,到了vue3,相信瀏覽器的性能起來,所以這里記錄一下,下面這篇文章主要給大家介紹了關(guān)于vue3+vite2中使用svg的相關(guān)資料,需要的朋友可以參考下2022-08-08
vue在IIS服務(wù)器部署后路由無法跳轉(zhuǎn)
在IIS服務(wù)器上部署Vue項(xiàng)目時(shí),可能會(huì)遇到路由無法正常跳轉(zhuǎn)的問題,解決方法有兩種,下面就來具體介紹一下解決方法,感興趣的可以了解一下2024-10-10
Vue3.0 響應(yīng)式系統(tǒng)源碼逐行分析講解
這篇文章主要介紹了Vue3.0 響應(yīng)式系統(tǒng)源碼逐行分析講解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
Vue 動(dòng)態(tài)生成數(shù)據(jù)字段的實(shí)例
這篇文章主要介紹了Vue 動(dòng)態(tài)生成數(shù)據(jù)字段的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04
如何使用crypto-js對(duì)文件上傳下載進(jìn)行加密處理
這篇文章主要介紹了如何使用crypto-js對(duì)文件上傳下載進(jìn)行加密處理方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05
Vue使用v-viewer插件實(shí)現(xiàn)圖片預(yù)覽和縮放和旋轉(zhuǎn)等功能(推薦)
v-viewer是一個(gè)基于viewerjs封裝的vue圖片預(yù)覽組件,有預(yù)覽縮放拉伸旋轉(zhuǎn)切換拖拽等功能,支持配置化,這篇文章主要介紹了Vue使用v-viewer插件實(shí)現(xiàn)圖片預(yù)覽和縮放和旋轉(zhuǎn)等功能,需要的朋友可以參考下2023-02-02

