perf: optimized page switching effect

This commit is contained in:
nebv
2020-10-11 01:13:27 +08:00
parent 03b6025d07
commit 5f2a927cd5
12 changed files with 47 additions and 40 deletions

View File

@@ -1,17 +1,7 @@
import type { MenuState } from './types';
import type { Menu as MenuType } from '/@/router/types';
import {
computed,
defineComponent,
unref,
reactive,
toRef,
watch,
onMounted,
watchEffect,
ref,
} from 'vue';
import { computed, defineComponent, unref, reactive, toRef, watch, onMounted, ref } from 'vue';
import { basicProps } from './props';
import { Menu } from 'ant-design-vue';
import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
@@ -106,11 +96,18 @@ export default defineComponent({
getParentPath();
}
);
watchEffect(() => {
if (props.items) {
handleMenuChange();
watch(
() => props.items,
() => {
if (props.items) {
handleMenuChange();
}
},
{
immediate: true,
}
});
);
async function getParentPath() {
const { appendClass } = props;