Skip to content

Commit

Permalink
fix(menu): currentActiveMenu fails after refresh #188
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 14, 2021
1 parent 0aeec5e commit 6d5c49f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Menu/src/BasicMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
emits: ['menuClick'],
setup(props, { emit }) {
const isClickGo = ref(false);
const currentActiveMenu = ref('');
const menuState = reactive<MenuState>({
defaultSelectedKeys: [],
Expand Down Expand Up @@ -118,10 +119,11 @@
listenerLastChangeTab((route) => {
if (route.name === REDIRECT_NAME) return;
handleMenuChange(route);
const currentActiveMenu = route.meta?.currentActiveMenu;
if (currentActiveMenu) {
menuState.selectedKeys = [currentActiveMenu];
setOpenKeys(currentActiveMenu);
currentActiveMenu.value = route.meta?.currentActiveMenu;
if (unref(currentActiveMenu)) {
menuState.selectedKeys = [unref(currentActiveMenu)];
setOpenKeys(unref(currentActiveMenu));
}
});
Expand Down Expand Up @@ -153,6 +155,7 @@
}
const path = (route || unref(currentRoute)).path;
setOpenKeys(path);
if (unref(currentActiveMenu)) return;
if (props.isHorizontal && unref(getSplit)) {
const parentPath = await getCurrentParentPath(path);
menuState.selectedKeys = [parentPath];
Expand Down

0 comments on commit 6d5c49f

Please sign in to comment.