600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > vue3 报错提示 找不到模块“./XXX.vue”或其相应的类型声明

vue3 报错提示 找不到模块“./XXX.vue”或其相应的类型声明

时间:2023-03-13 11:11:47

相关推荐

vue3 报错提示 找不到模块“./XXX.vue”或其相应的类型声明

vue3 报错提示 找不到模块“./XXX.vue”或其相应的类型声明

从网上找了好多方法比如在tsconfig文件下增加:

{"compilerOptions": {"baseUrl": "./","paths": {"@/*": ["src/*"]}},"exclude": ["node_modules","dist"]}

这对我来说根本没有用。

后来看到说可以在src根目录下创建一个后缀为.d.ts的文件,

写上以下代码:

declare module '*.vue' {import type { DefineComponent } from 'vue'// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-typesconst component: DefineComponent<{}, {}, any>export default component}

问题解决了,不再报模块找不到的错误了

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。