1. 程式人生 > 實用技巧 >記錄 D2-admin 側邊欄 二級路由高亮問題

記錄 D2-admin 側邊欄 二級路由高亮問題

側邊選單欄採用了element ui 的el-menu元件,用到了default-active和router屬性

分三步走

第一步,在el-menu 中新增router='true' 和 default-active = { this.$route.meta.name } 屬性

--this.$route.meta.name 為路由表中配置

第二步, 在el-menu-item 中 新增 router = { menu.path}

第三步, 在路由表中新增自定義屬性meta.name 的值

-- 例如

path: '/',

component: '........',

children: [

{ path: 'index', component: '..........', meta: { title: '首頁', auth: true, name: '/index' }}

]

搞定收工