mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 11:11:55 +08:00
v3.7.0 顶部菜单排除隐藏的默认路由
This commit is contained in:
parent
ba74c587b7
commit
2579e8549e
@ -87,7 +87,7 @@ export default {
|
|||||||
// 默认激活的菜单
|
// 默认激活的菜单
|
||||||
activeMenu() {
|
activeMenu() {
|
||||||
const path = this.$route.path;
|
const path = this.$route.path;
|
||||||
let activePath = this.routers[0].path;
|
let activePath = this.defaultRouter();
|
||||||
if (path.lastIndexOf("/") > 0) {
|
if (path.lastIndexOf("/") > 0) {
|
||||||
const tmpPath = path.substring(1, path.length);
|
const tmpPath = path.substring(1, path.length);
|
||||||
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
||||||
@ -100,7 +100,7 @@ export default {
|
|||||||
}
|
}
|
||||||
var routes = this.activeRoutes(activePath);
|
var routes = this.activeRoutes(activePath);
|
||||||
if (routes.length === 0) {
|
if (routes.length === 0) {
|
||||||
activePath = this.currentIndex || this.routers[0].path
|
activePath = this.currentIndex || this.defaultRouter()
|
||||||
this.activeRoutes(activePath);
|
this.activeRoutes(activePath);
|
||||||
}
|
}
|
||||||
return activePath;
|
return activePath;
|
||||||
@ -121,6 +121,17 @@ export default {
|
|||||||
const width = document.body.getBoundingClientRect().width / 3;
|
const width = document.body.getBoundingClientRect().width / 3;
|
||||||
this.visibleNumber = parseInt(width / 85);
|
this.visibleNumber = parseInt(width / 85);
|
||||||
},
|
},
|
||||||
|
// 默认激活的路由
|
||||||
|
defaultRouter() {
|
||||||
|
let router;
|
||||||
|
Object.keys(this.routers).some((key) => {
|
||||||
|
if (!this.routers[key].hidden) {
|
||||||
|
router = this.routers[key].path;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return router;
|
||||||
|
},
|
||||||
// 菜单选择事件
|
// 菜单选择事件
|
||||||
handleSelect(key, keyPath) {
|
handleSelect(key, keyPath) {
|
||||||
this.currentIndex = key;
|
this.currentIndex = key;
|
||||||
|
Loading…
Reference in New Issue
Block a user