Cannot find module './App.vue' or its corresponding type declarations.

src下新增或者修改vite-env.d.ts文件

/**
 * vite-env.d.ts的作用
 * 为了 typescript 做的适配定义文件,因为.vue 文件不是一个常规的文件类型,ts 是不能理解 vue 文件是干嘛的,
 * 加这一段是是告诉 ts,vue 文件是这种类型的。
 * 可以把这一段删除,会发现 import 的所有 vue 类型的文件都会报错。
 * 
 * 在tsconfig.json中加入include *.ts
 */
declare module '*.vue' {
    import type { DefineComponent } from 'vue'
    const component: DefineComponent<{}, {}, any>
    export default component
}

 

posted @ 2025-08-23 02:17  猪脚踏浪  阅读(63)  评论(0)    收藏  举报