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;
}
相关推荐
徐小夕2 分钟前
Loop Engineering 深度解析与实战指南(全网最全)
前端·算法·github
运筹vivo@16 分钟前
Python ContextVar 底层机制与内存模型拆解
前端·数据库·python
#麻辣小龙虾#2 小时前
基于vue3.0开发一款【固废与废气运维管理系统】(支持源码)
前端·vue.js·vue3
Cosolar2 小时前
Docsify零构建文档站完全指南:从快速搭建到企业级部署
前端·开源·github
weixin_471383032 小时前
Taro-02-页面路由
前端·taro
星栈独行2 小时前
Makepad 应用如何读文件、调接口、保存数据
前端·程序人生·ui·rust·github
IT_陈寒3 小时前
Vite热更新失效?可能你在用Windows
前端·人工智能·后端
tedcloud1233 小时前
taste-skill部署教程:打造个性化AI推荐工作流
服务器·前端·人工智能·系统架构·edge
xinhuanjieyi3 小时前
html修复游戏种太阳错误
前端·游戏·html
林希_Rachel_傻希希4 小时前
学React治好了我的焦虑症,1小时速通React 前20分钟。
前端·javascript·面试