v3.8.2 topNav自定义隐藏侧边栏路由
This commit is contained in:
parent
d6ef0ccd60
commit
540595646d
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<el-menu
|
<el-menu
|
||||||
:default-active="activeMenu"
|
:default-active="activeMenu"
|
||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
@select="handleSelect"
|
@select="handleSelect"
|
||||||
>
|
>
|
||||||
<template v-for="(item, index) in topMenus">
|
<template v-for="(item, index) in topMenus">
|
||||||
<el-menu-item :style="{'--theme': theme}" :index="item.path" :key="index" v-if="index < visibleNumber"
|
<el-menu-item :style="{'--theme': theme}" :index="item.path" :key="index" v-if="index < visibleNumber"
|
||||||
|
@ -16,9 +16,9 @@
|
||||||
<template slot="title">更多菜单</template>
|
<template slot="title">更多菜单</template>
|
||||||
<template v-for="(item, index) in topMenus">
|
<template v-for="(item, index) in topMenus">
|
||||||
<el-menu-item
|
<el-menu-item
|
||||||
:index="item.path"
|
:index="item.path"
|
||||||
:key="index"
|
:key="index"
|
||||||
v-if="index >= visibleNumber"
|
v-if="index >= visibleNumber"
|
||||||
><svg-icon :icon-class="item.meta.icon" />
|
><svg-icon :icon-class="item.meta.icon" />
|
||||||
{{ item.meta.title }}</el-menu-item
|
{{ item.meta.title }}</el-menu-item
|
||||||
>
|
>
|
||||||
|
@ -30,13 +30,14 @@
|
||||||
<script>
|
<script>
|
||||||
import { constantRoutes } from "@/router";
|
import { constantRoutes } from "@/router";
|
||||||
|
|
||||||
|
// 隐藏侧边栏路由
|
||||||
|
const hideList = ['/index', '/user/profile'];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 顶部栏初始数
|
// 顶部栏初始数
|
||||||
visibleNumber: 5,
|
visibleNumber: 5,
|
||||||
// 是否为首次加载
|
|
||||||
isFrist: false,
|
|
||||||
// 当前激活菜单的 index
|
// 当前激活菜单的 index
|
||||||
currentIndex: undefined
|
currentIndex: undefined
|
||||||
};
|
};
|
||||||
|
@ -88,17 +89,10 @@ export default {
|
||||||
activeMenu() {
|
activeMenu() {
|
||||||
const path = this.$route.path;
|
const path = this.$route.path;
|
||||||
let activePath = path;
|
let activePath = path;
|
||||||
if (path.lastIndexOf("/") > 0) {
|
if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) {
|
||||||
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("/"));
|
||||||
this.$store.dispatch('app/toggleSideBarHide', false);
|
this.$store.dispatch('app/toggleSideBarHide', false);
|
||||||
} else if ("/index" == path || "" == path) {
|
|
||||||
if (!this.isFrist) {
|
|
||||||
this.isFrist = true;
|
|
||||||
} else {
|
|
||||||
activePath = "index";
|
|
||||||
}
|
|
||||||
this.$store.dispatch('app/toggleSideBarHide', true);
|
|
||||||
} else if(!this.$route.children) {
|
} else if(!this.$route.children) {
|
||||||
activePath = path;
|
activePath = path;
|
||||||
this.$store.dispatch('app/toggleSideBarHide', true);
|
this.$store.dispatch('app/toggleSideBarHide', true);
|
||||||
|
|
Loading…
Reference in New Issue