启动vue2+ts项目虽然页面能够正常运行,但是堆栈报错如下:
ERROR in /fe-hz-projects/node_modules/vue-router/types/composables.d.ts(1,15):
1:15 Module '"../../vue/types"' has no exported member 'ComputedRef'. Did you mean to use 'import ComputedRef from "../../vue/types"' instead?
> 1 | import type { ComputedRef, Ref } from 'vue'
| ^
2 | import type { Route, NavigationGuard, default as VueRouter } from './index'
3 |
4 |
ERROR in /fe-hz-projects/node_modules/vue-router/types/composables.d.ts(1,28):
1:28 Module '"../../vue/types"' has no exported member 'Ref'. Did you mean to use 'import Ref from "../../vue/types"' instead?
> 1 | import type { ComputedRef, Ref } from 'vue'
| ^
2 | import type { Route, NavigationGuard, default as VueRouter } from './index'
Version: typescript 3.9.10
网上有些解决方案说是将当前ts升级到4.3.5即可,但是楼主升级到4.3.5之后报错更多,并且仍然存在上述错误
解决方案:无需升级ts版本,手动删除node_modules文件夹中的vue-router文件夹,终端执行npm install vue-router@3.0.1即可解决上述报错