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;
}
相关推荐
妄小闲几秒前
网页设计模板 HTML源码网站模板下载
前端·html
icebreaker17 分钟前
tailwindcss 究竟比 unocss 快多少?
前端·css·github
卢叁22 分钟前
Flutter之自定义TabIndicator
前端·flutter
每天吃饭的羊34 分钟前
state和ref
前端·javascript·react.js
GEO_YScsn35 分钟前
Vite:Next-Gen Frontend Tooling 的高效之道——从原理到实践的性能革命
前端·javascript·css·tensorflow
GISer_Jing35 分钟前
滴滴二面(准备二)
前端·javascript·vue·reactjs
ningmengjing_39 分钟前
webpack打包方式
前端·爬虫·webpack·node.js·逆向
Yuner200041 分钟前
Webpack开发:从入门到精通
前端·webpack·node.js
GISer_Jing43 分钟前
滴滴二面准备(一)
前端·javascript·面试·ecmascript
lecepin1 小时前
AI Coding 资讯 2025-09-10
前端·javascript·面试