若依-侧边栏开关按钮禁用,侧边栏始终保持展开
若依框架,当首页为echarts图时,侧边栏展开关闭echarts会超出
解决思路:
当菜单为首页时,侧边栏开关按钮禁用,侧边栏始终保持展开
\src\store\modules\app.js
toggleSideBar(withoutAnimation, typeVal) {
if (typeVal == 1) {
this.sidebar.opened = true
Cookies.set('sidebarStatus', 1)
return
};
if (this.sidebar.hide) {
return false;
}
this.sidebar.opened = !this.sidebar.opened
this.sidebar.withoutAnimation = withoutAnimation
if (this.sidebar.opened) {
Cookies.set('sidebarStatus', 1)
} else {
Cookies.set('sidebarStatus', 0)
}
},
控制页头的按钮
\src\layout\components\Navbar.vue
function toggleSideBar() {
if (route.path == "/index") {
appStore.toggleSideBar("", 1);
return;
}
appStore.toggleSideBar();
}
从其他菜单跳转到首页,让首页展开
\src\router\index.js
import useAppStore from "@/store/modules/app";
router.beforeEach((to, from, next) => {
const appStore = useAppStore();
if (to.path == '/index') {
appStore.toggleSideBar("", 1);
}
next()
})