vue+element三級動(dòng)態(tài)側(cè)邊欄

最近一直在做后臺管理的項(xiàng)目,側(cè)邊欄肯定是少不了的,一般比較大型的項(xiàng)目側(cè)邊欄肯定不是一級二級就能搞定的,去年開發(fā)的時(shí)候就涉及到了四級動(dòng)態(tài)菜單研究了好久才渲染折疊才可以,但沒有記筆記,所以再次開發(fā)的時(shí)候又想不起來了,嗚嗚嗚~~~所以今天就做個(gè)筆記了方便日后查看

1.router.js

{

? ? ? ? path:'/systemManage', name: "systemManage", meta: { requireAuth: true, title: '系統(tǒng)管理', icon: ''}, component: () => import('@/views/system/index.vue'),

? ? ? ? children:[

? ? ? ? ? ? {? path: '/colony', name: "colony",redirect: '/namespace', meta: { requireAuth: true, title: '集群',? ? icon: ''}, component: () => import('@/views/system/colony/index.vue'),

? ? ? ? ? ? ? ? children:[

? ? ? ? ? ? ? ? ? ? { path: '/namespace', name: "namespace", meta: { requireAuth: true, title: '命名空間', icon: ''}, component: () => import('@/views/system/colony/namespace.vue') }

? ? ? ? ? ? ? ? ]

? ? ? ? ? ? },

2.navigate.vue

<el-menu

? ? ? ? ? ? :default-active="ActiveIndex"

? ? ? ? ? ? :router="true"

? ? ? ? ? ? class="el-menu-demo"

? ? ? ? ? ? mode="vertical"

? ? ? ? ? ? :collapse="isOpen"

? ? ? ? ? ? @select="handleSelect"

? ? ? ? ? ? >

? ? ? ? ? ? ? ? <el-menu-item :index="itme.PTo" v-if="!itme.children" v-for="(itme, index) in Path" :key="index">

? ? ? ? ? ? ? ? ? ? <i :class="itme.icon"></i>

? ? ? ? ? ? ? ? ? ? <span>{{ itme.name }}</span>

? ? ? ? ? ? ? ? </el-menu-item>

? ? ? ? ? ? ? ? <el-submenu :index="itme.PTo" v-for="(itme, index) in Path"? v-if="itme.children && itme.children.length>0" :key="index">

? ? ? ? ? ? ? ? ? ? <template slot="title">

? ? ? ? ? ? ? ? ? ? ? ? <i :class="itme.icon"></i>

? ? ? ? ? ? ? ? ? ? ? ? <span>{{ itme.name }}</span>

? ? ? ? ? ? ? ? ? ? </template>

? ? ? ? ? ? ? ? ? ? <el-menu-item :index="itmes.PTo" v-for="(itmes, index) in itme.children" v-if="!itmes.children" :key="index">

? ? ? ? ? ? ? ? ? ? ? ? <i :class="itmes.icon"></i>

? ? ? ? ? ? ? ? ? ? ? ? <span>{{ itmes.name }}</span>

? ? ? ? ? ? ? ? ? ? </el-menu-item>

? ? ? ? ? ? ? ? ? ? <el-submenu :index="item.PTo" v-for="(item, index) in itme.children"? v-if="item.children && item.children.length>0" :key="index">

? ? ? ? ? ? ? ? ? ? ? ? <template slot="title">

? ? ? ? ? ? ? ? ? ? ? ? ? ? <i :class="item.icon"></i>

? ? ? ? ? ? ? ? ? ? ? ? ? ? <span>{{ item.name }}</span>

? ? ? ? ? ? ? ? ? ? ? ? </template>

? ? ? ? ? ? ? ? ? ? ? ? <el-menu-item :index="items.PTo" v-for="(items, index) in item.children" :key="index">

? ? ? ? ? ? ? ? ? ? ? ? ? ? <i :class="items.icon"></i>

? ? ? ? ? ? ? ? ? ? ? ? ? ? <span>{{ items.name }}</span>

? ? ? ? ? ? ? ? ? ? ? ? </el-menu-item>

? ? ? ? ? ? ? ? ? ? </el-submenu>?

? ? ? ? ? ? ? ? </el-submenu>

? ? ? ? ? ? </el-menu>

data(){

????return {

????????path:[{

? ? ? ? ? ? ? ? ? ? indexPath: "4",

? ? ? ? ? ? ? ? ? ? PTo: "/systemManage",

? ? ? ? ? ? ? ? ? ? name: "系統(tǒng)管理",

? ? ? ? ? ? ? ? ? ? icon: "el-icon-setting",

? ? ? ? ? ? ? ? ? ? children:[

? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ? indexPath: "4-3",

? ? ? ? ? ? ? ? ? ? ? ? ? ? PTo: "/colony",

? ? ? ? ? ? ? ? ? ? ? ? ? ? name: "集群",

? ? ? ? ? ? ? ? ? ? ? ? ? ? icon: "el-icon-reading",

? ? ? ? ? ? ? ? ? ? ? ? ? ? children:[

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? indexPath: "4-3-1",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PTo: "/namespace",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? name: "命名空間",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? icon: "el-icon-house"

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? }

????????]

? ? }

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容