一、ide不能解析vue文件
刚开始导入时,在vscode中的vue文件中内容都是灰色的
![](https://img-blog.csdnimg.cn/direct/ba6837ae7c2e4a2aac5865eb94bc25a3.png)
ide不能解析vue解决方法:
1.idea或webstorm安装vue.js插件
2.在vscode中
- vue2.0的项目安装vetur插件
- vue3.0及以上的项目安装Vue-official插件(之前是Volar)
vue官方推荐:搭配 TypeScript 使用 Vue | Vue.js (vuejs.org)
![](https://img-blog.csdnimg.cn/direct/8e70d706e30640c1865a8534f4b769ab.png)
二、ts文件不能解析.vue
bash
Could not find a declaration file for module '../views/Index.vue'. 'd:/project/panda/src/views/Index.vue' implicitly has an 'any' type.
![](https://img-blog.csdnimg.cn/direct/68263674c19e4ce49bc948bb1c3a068a.png)
![](https://img-blog.csdnimg.cn/direct/85d38752db9e41ae92d21ae8f44c97d3.png)
ts不能解析*.vue解决办法:
方式一、在tsconfig.json中配置 "compilerOptions": {.... "allowJs": true, }
![](https://img-blog.csdnimg.cn/direct/6b18e6fa06b4476fb96e40e56bb4d334.png)
方式二、找到vite-env.d.ts文件或者env.d.ts文件,添加如下代码
TypeScript
declare module '*.vue' {
import type { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
![](https://img-blog.csdnimg.cn/direct/dd9bba6292a44746b8014a2d341c697b.png)