vbenjs / vben3

Next-generation Vben framework
https://vben.mufei88.com/
MIT License
557 stars 155 forks source link

pnpm dev 报错 #355

Open FreeLzn opened 2 months ago

FreeLzn commented 2 months ago
falcon-jin commented 2 months ago

e4458076abf80a5f3c7459cecd2b15a 加个这个

M69W commented 1 month 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.

f6efaf92c3ae1cb14cf46ca06006ecac

临时解决

--- 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>