处理web模块一级菜单不默认展开的问题

This commit is contained in:
renpy 2023-08-23 17:20:01 +08:00
parent 54877142f5
commit ab87528cca

View File

@ -104,22 +104,27 @@ export default {
console.log("路由信息",this.menus);
// this.initDefaultKeys(this.menus[0])
// openKeys
const openKeys = window.sessionStorage.getItem('openKeys')
// const openKeys = window.sessionStorage.getItem('openKeys')
const selectedKeys = window.sessionStorage.getItem('currMenu')
if (selectedKeys) {
this.defaultSelectedKeys.push(selectedKeys)
} else {
this.initDefaultKeys(this.menus[0])
}
if (openKeys) {
//
this.defaultOpenKeys = JSON.parse(openKeys)
}
if (openKeys) {
//
this.openKeys = JSON.parse(openKeys)
this.defaultSelectedKeys.push(selectedKeys)
} else {
this.initDefaultKeys(this.menus[0])
}
console.log(this.menus);
this.menus.forEach(item => {
if (item.name!=="istatistics-data") {
this.defaultOpenKeys.push(item.path)
}
})
// if (openKeys) {
// //
// this.defaultOpenKeys = JSON.parse(openKeys)
// }
// if (openKeys) {
// //
// this.openKeys = JSON.parse(openKeys)
// }
},
methods: {
// ,MenuItem
@ -135,17 +140,24 @@ export default {
},
initDefaultKeys(data) {
this.defaultOpenKeys.push(data.path)
data.children.some((f) => {
if (f.children) {
//
this.defaultOpenKeys.push(f.path)
this.initDefaultKeys(f.children[0])
} else {
//
this.defaultSelectedKeys.push(f.path)
return true
// if (data.children) {
if (data.name!=="istatistics-StateOfHealth-alerts") {
data.children.some((f) => {
if (f.children) {
//
this.defaultOpenKeys.push(f.path)
this.initDefaultKeys(f.children[0])
} else {
//
this.defaultSelectedKeys.push(f.path)
return true
}
})
}
})
// } else {
// this.defaultOpenKeys.push(data.path)
// }
},
onOpenChange(openKeys) {
//