From 1ed60997f2c06e59bb47d719b6576a88be6d22ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=82=A0=E9=9D=99=E8=90=9D=E8=8E=89?= Date: Sat, 30 Mar 2024 03:20:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7Vue3.4=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DRoute=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E9=80=A0=E6=88=90=E4=B8=80=E7=B3=BB=E5=88=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 +++--- src/router/index.ts | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3673697f..fc375943 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,11 @@ "qrcode.vue": "^3.4.1", "qs": "^6.11.2", "tdesign-icons-vue-next": "^0.2.2", - "tdesign-vue-next": "^1.8.1", + "tdesign-vue-next": "^1.9.3", "tvision-color": "^1.6.0", - "vue": "~3.3.8", + "vue": "~3.4.21", "vue-i18n": "^9.9.1", - "vue-router": "~4.2.5" + "vue-router": "~4.3.0" }, "devDependencies": { "@commitlint/cli": "^18.6.0", diff --git a/src/router/index.ts b/src/router/index.ts index 50764296..bcd69ed8 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,5 +1,5 @@ import uniq from 'lodash/uniq'; -import { createRouter, createWebHistory, RouteRecordRaw, useRoute } from 'vue-router'; +import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'; const env = import.meta.env.MODE || 'development'; @@ -59,7 +59,8 @@ export const getRoutesExpanded = () => { }; export const getActive = (maxLevel = 3): string => { - const route = useRoute(); + // 非组件内调用必须通过Router实例获取当前路由 + const route = router.currentRoute.value; if (!route.path) { return '';