mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 04:16:30 +08:00
fix: 修复多级菜单高亮问题 (#459)
This commit is contained in:
parent
4293d30180
commit
ba9a918d99
|
@ -38,7 +38,6 @@ const props = defineProps({
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const active = computed(() => getActive());
|
const active = computed(() => getActive());
|
||||||
|
|
||||||
const list = computed(() => {
|
const list = computed(() => {
|
||||||
|
@ -85,9 +84,16 @@ const getHref = (item: MenuRoute) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPath = (item: ListItemType) => {
|
const getPath = (item: ListItemType) => {
|
||||||
|
const activeLevel = active.value.split('/').length;
|
||||||
|
const pathLevel = item.path.split('/').length;
|
||||||
|
if (activeLevel > pathLevel && active.value.startsWith(item.path)) {
|
||||||
|
return active.value;
|
||||||
|
}
|
||||||
|
|
||||||
if (active.value === item.path) {
|
if (active.value === item.path) {
|
||||||
return active.value;
|
return active.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.meta?.single ? item.redirect : item.path;
|
return item.meta?.single ? item.redirect : item.path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user