1、采用top导航
首页打开自动隐藏左边栏
1)切换时自动关闭首页左边栏
修改@/componets/Breadcrumb.vue文件
getBreadcrumb() {
// only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
const first = matched[0]
if (!this.isDashboard(first)) {
matched = [{ path: '/dashboard', meta: { title: '首页' }}].concat(matched)
}else{
//增加此行代码:首页关闭左边栏
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
}
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
},
2)登录后到首页自动关闭导航栏
修改@/layout/components/Topbar.vue
// 设置侧边栏的显示和隐藏
setSidebarHide(route) {
if (!route.children || route.children.length === 1) {
//默认关闭
this.$store.dispatch('app/closeSideBar', { withoutAnimation: true })
} else {
//默认打开
this.$store.dispatch('app/openSideBar', { withoutAnimation: false })
}
},