feat: 混合布局的左侧树关联
This commit is contained in:
parent
28db7e85a1
commit
c31c15c244
@ -84,18 +84,31 @@ const onMenuItem = (key: string) => {
|
|||||||
const find = findLinearArray(key);
|
const find = findLinearArray(key);
|
||||||
// 路由存在则存入并跳转,不存在则跳404
|
// 路由存在则存入并跳转,不存在则跳404
|
||||||
if (find) {
|
if (find) {
|
||||||
// 将父级的chindren给左侧树
|
setAsideMenu(find);
|
||||||
if (find.children && find.children.length > 0) {
|
|
||||||
routeList.value = find.children;
|
|
||||||
} else {
|
|
||||||
// 如果没有则直接将父级给左侧树,做一级兜底
|
|
||||||
routeList.value = [find];
|
|
||||||
}
|
|
||||||
router.push(find.path);
|
router.push(find.path);
|
||||||
} else {
|
} else {
|
||||||
router.push("/404");
|
router.push("/404");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 给左侧树赋值
|
||||||
|
const setAsideMenu = (find: Menu.MenuOptions) => {
|
||||||
|
// 将父级的chindren给左侧树
|
||||||
|
if (find.children && find.children.length > 0) {
|
||||||
|
routeList.value = find.children;
|
||||||
|
} else {
|
||||||
|
// 如果没有则直接将父级给左侧树,做一级兜底
|
||||||
|
routeList.value = [find];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 首次进入,获取左侧菜单
|
||||||
|
const getAsideMenu = (key: string) => {
|
||||||
|
const { findLinearArray } = useRoutingMethod();
|
||||||
|
const find = findLinearArray(key);
|
||||||
|
setAsideMenu(find);
|
||||||
|
};
|
||||||
|
getAsideMenu(aciveRoute.value as string);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user