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

problem

Cannot find module ‘…/views/HomeView.vue’ or its corresponding type declarations.ts
版本:vue3 ts
请添加图片描述

reason

ts无法识别 vue 文件

solution

在根路径下 env.d.ts 添加以下声明

//  env.d.ts 
// 这个文件生效的前提是 tsconfig.json 中配置了 "include": ["env.d.ts"],
declare module '*.vue' {import { DefineComponent } from 'vue';// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-typesconst component: DefineComponent<{}, {}, any>;export default component;
}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部