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

解决方法:

1、在src根目录下创建一个文件env.d.ts的文件

2、在文件上写上以下内容:

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
  }

注:文件名可以为其它,只要后缀为.d.ts即可。

你可能感兴趣的:(前端技术,vue.js,typescript,javascript)