Cannot find module ‘../views/xx.vue‘ or its corresponding type declarations.ts

搭建vue3项目时,报Cannot find module '../views/xx.vue' or its corresponding type declarations.ts错误:

原因:因为ts只能解析 .ts 文件,无法解析 .vue文件

解决方案:在项目根目录下的env.d.ts文件里面输入如下代码

declare module '*.vue' {
  import { DefineComponent } from 'vue';
  const component: DefineComponent<{}, {}, any>;
  export default component;
}

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-14 11:38:06       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-14 11:38:06       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-14 11:38:06       82 阅读
  4. Python语言-面向对象

    2024-04-14 11:38:06       91 阅读

热门阅读

  1. 合并STM32的bootloader和app程序的hex文件的方法

    2024-04-14 11:38:06       40 阅读
  2. ssh运行base64编码的命令

    2024-04-14 11:38:06       96 阅读
  3. CSS训练

    CSS训练

    2024-04-14 11:38:06      36 阅读
  4. 什么是渐进式框架

    2024-04-14 11:38:06       129 阅读
  5. 如何学习JVM的知识

    2024-04-14 11:38:06       41 阅读
  6. CentOS 7启动数据库服务失败

    2024-04-14 11:38:06       34 阅读
  7. 【R: mlr3:超参数调优】

    2024-04-14 11:38:06       36 阅读
  8. mac ip 域名 三者之间的关系

    2024-04-14 11:38:06       33 阅读