处理页面中跳转页面,左侧二级菜单高亮菜单与路由地址不匹配的问题
This commit is contained in:
parent
20f52d06e1
commit
fb2f8c9f11
|
@ -5,8 +5,8 @@
|
|||
<div style="height:100%">
|
||||
<a-menu
|
||||
id="dddddd"
|
||||
:defaultSelectedKeys="defaultSelectedKeys"
|
||||
:defaultOpenKeys="defaultOpenKeys"
|
||||
v-model="currSlecteKey"
|
||||
mode="inline"
|
||||
:inline-collapsed="collapsed"
|
||||
@openChange="onOpenChange"
|
||||
|
@ -90,6 +90,7 @@ export default {
|
|||
openKeys: [],
|
||||
// 选中的子菜单项
|
||||
defaultSelectedKeys: [],
|
||||
currSlecteKey: [],
|
||||
defaultOpenKeys: [],
|
||||
rootSubmenuKeys: ['/istatistics/imsData', '/istatistics'],
|
||||
}
|
||||
|
@ -109,7 +110,8 @@ export default {
|
|||
// console.log(openKeys);
|
||||
const selectedKeys = window.sessionStorage.getItem('currMenu')
|
||||
if (selectedKeys) {
|
||||
this.defaultSelectedKeys.push(selectedKeys)
|
||||
// this.defaultSelectedKeys.push(selectedKeys)
|
||||
this.currSlecteKey.push(selectedKeys)
|
||||
} else {
|
||||
|
||||
this.initDefaultKeys(this.menus[0])
|
||||
|
@ -126,19 +128,34 @@ export default {
|
|||
// this.openKeys = JSON.parse(openKeys)
|
||||
// }
|
||||
},
|
||||
watch: {
|
||||
"$route": {
|
||||
handler: function (val, oldVal) {
|
||||
this.currSlecteKey=[]
|
||||
console.log(val);
|
||||
this.currSlecteKey.push(val.path)
|
||||
window.sessionStorage.setItem('currMenu', val.path)
|
||||
},
|
||||
deep:true,
|
||||
immediate:true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 点击菜单,路由跳转,注意的是当点击MenuItem才会触发此函数
|
||||
menuClick({ item, key, keyPath }) {
|
||||
this.currSlecteKey =[]
|
||||
window.sessionStorage.setItem('currMenu', key)
|
||||
// var parentPath = item._props.parentMenu._props.eventKey;
|
||||
// var parentTitle = parentPath.substring(parentPath.lastIndexOf("/") + 1, parentPath.length)
|
||||
// var par = {"type": "q"}
|
||||
// 获取到当前的key,并且跳转
|
||||
this.currSlecteKey.push(key)
|
||||
this.$router.push({
|
||||
path: key,
|
||||
})
|
||||
},
|
||||
initDefaultKeys(data) {
|
||||
this.currSlecteKey=[]
|
||||
console.log("datadefaultOpenKeys",data);
|
||||
this.defaultOpenKeys.push(data.path)
|
||||
data.children.some((f) => {
|
||||
|
@ -148,7 +165,8 @@ export default {
|
|||
this.initDefaultKeys(f.children[0])
|
||||
} else {
|
||||
// 选中
|
||||
this.defaultSelectedKeys.push(f.path)
|
||||
// this.defaultSelectedKeys.push(f.path)
|
||||
this.currSlecteKey.push(f.path)
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
|
|
@ -325,7 +325,6 @@ export default {
|
|||
this.visible = false
|
||||
},
|
||||
onRowDbclick(record) {
|
||||
console.log(record);
|
||||
let query = {
|
||||
serverId:record.id
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user