Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

pnpm dev 报错 #355

Open
FreeLzn opened this issue Jul 2, 2024 · 2 comments
Open

pnpm dev 报错 #355

FreeLzn opened this issue Jul 2, 2024 · 2 comments

Comments

@FreeLzn
Copy link

FreeLzn commented Jul 2, 2024

  • Operating System: windows
  • Node version: 20.13.1
  • npm version: 10.7.0
  • Package manager (npm/yarn/pnpm) and version: pnpm 9.4
    新clone下来的代码,使用pnpm install安装好依赖之后,执行pnpm dev 报错。报错图片如下:
    WechatIMG13
@falcon-jin
Copy link

e4458076abf80a5f3c7459cecd2b15a
加个这个

@M69W
Copy link

M69W commented Jul 24, 2024

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>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants