Skip to content

Commit

Permalink
feat: 升级Vue3.4,修复Route调用方式造成一系列问题
Browse files Browse the repository at this point in the history
  • Loading branch information
timi137137 committed Mar 29, 2024
1 parent 0f7096a commit 1ed6099
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 '';
Expand Down

0 comments on commit 1ed6099

Please sign in to comment.