![](https://i-blog.csdnimg.cn/blog_migrate/6464e3f2d97460b38932c177193722e5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/44c2e8f135e22a5493fcadbc5d4403ee.png)
相应的遇到这种问题 会很苦恼 ,程序能够执行,但是对于我们一部分人来说,一直看着报错 是真的难受!
解决方法:
![](https://i-blog.csdnimg.cn/blog_migrate/160e6501fb528c169f7be14500419aca.png)
在最外层的目录下新建一个env.d.ts文件
// <reference types="vite/client" />
// vue3 报错提示 找不到模块“./XXX.vue”或其相应的类型声明
// 报错原因:typescript 只能理解 .ts 文件,无法理解 .vue文件
declare module '*.vue' {
import type { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;
}
![](https://i-blog.csdnimg.cn/blog_migrate/160e6501fb528c169f7be14500419aca.png)
保存后 ,你就会惊奇的发现,原先报错的代码,不再报错了
当然也有最简版的方法:
找到对应的eslint 的扩展 将它关闭,或者是将对应的设置关闭,不过这对于团队开发的话。会有所影响~