循環(huán)傳入的數(shù)據(jù)去生成下級菜單
<template> <div class="headBar"> <div class="title"> 微商城管理后臺 </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)計', 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>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)頁標(biāo)題:vue側(cè)邊欄動態(tài)生成下級菜單的方法-創(chuàng)新互聯(lián)
URL標(biāo)題:http://jinyejixie.com/article48/jgohp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、商城網(wǎng)站、移動網(wǎng)站建設(shè)、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容