Open FreeLzn opened 2 months ago
加个这个
node -v
v18.18.2
pnpm -v
9.1.2
windows 10
pnpm dev
选择 admin
跳转路由报错:
Cannot destructure property 'currentRoute' of 'useRouter(...)' as it is undefined.
pnpm build
选 admin
Cannot destructure property 'currentRoute' of 'useRouter(...)' as it is undefined.
--- a/packages/stores/src/modules/multipleTab.ts
+++ b/packages/stores/src/modules/multipleTab.ts
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
-import { toRaw, unref } from 'vue'
+import { computed, toRaw, unref } from 'vue'
import {
PAGE_NOT_FOUND_NAME,
PageEnum,
@@ -14,6 +14,8 @@ import type {
import { getRawRoute, RemovableRef } from '@vben/utils'
import { useRouter } from 'vue-router'
+const currentRoute = computed(() => useRouter())
+
function handleGotoPage(router: Router, route?: RouteLocationNormalized) {
const currentPath = unref(router.currentRoute).path
// check if current route in tablist
@@ -391,7 +393,6 @@ export const useMultipleTab = defineStore({
getTabActions(tabItem: RouteLocationNormalized) {
if (!tabItem) return
const { meta } = tabItem
- const { currentRoute } = useRouter()
const { path } = unref(currentRoute)
const isCurItem = tabItem ? tabItem.path === path : false
F:\vben3>