Browse Source

reactor:简化引入写法;

zhangchong 1 năm trước cách đây
mục cha
commit
9553b01fd4
1 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 5 4
      src/layout/navMenu/vertical.vue

+ 5 - 4
src/layout/navMenu/vertical.vue

@@ -32,7 +32,7 @@
 
 <script setup lang="ts" name="navMenuVertical">
 import { defineAsyncComponent, reactive, computed, onMounted, watch } from 'vue';
-import { useRoute, onBeforeRouteUpdate, RouteRecordRaw } from 'vue-router';
+import { useRoute, onBeforeRouteUpdate, RouteRecordRaw, useRouter } from 'vue-router';
 import { storeToRefs } from 'pinia';
 import { useThemeConfig } from '@/stores/themeConfig';
 import { verifyUrl } from '@/utils/toolsValidate';
@@ -53,9 +53,10 @@ const props = defineProps({
 const storesThemeConfig = useThemeConfig();
 const { themeConfig } = storeToRefs(storesThemeConfig);
 const route = useRoute();
+const router = useRouter();
 const state = reactive({
 	// 修复:https://gitee.com/lyt-top/vue-next-admin/issues/I3YX6G
-	defaultActive: route.meta.isDynamic ? route.meta.isDynamicPath : route.path,
+	defaultActive: route.meta?.isDynamic ? route.meta?.isDynamicPath : route.path,
 	isCollapse: false,
 });
 
@@ -78,8 +79,8 @@ const setParentHighlight = (currentRoute: RouteToFrom) => {
 const onALinkClick = (val: RouteItem) => {
 	const { origin, pathname } = window.location;
 	router.push(val.path);
-	if (verifyUrl(val.meta.isLink)) window.open(val.meta.isLink);
-	else window.open(`${origin}${pathname}#${val.meta.isLink}`);
+	if (verifyUrl(<string>val.meta?.isLink)) window.open(val.meta?.isLink);
+	else window.open(`${origin}${pathname}#${val.meta?.isLink}`);
 };
 // 页面加载时
 onMounted(() => {