idea或vscode支持vue语法,ts可解析*.vue

一、ide不能解析vue文件

刚开始导入时,在vscode中的vue文件中内容都是灰色的

ide不能解析vue解决方法:

1.idea或webstorm安装vue.js插件

2.在vscode中

  • vue2.0的项目安装vetur插件
  • vue3.0及以上的项目安装Vue-official插件(之前是Volar)

vue官方推荐:搭配 TypeScript 使用 Vue | Vue.js (vuejs.org)

二、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.

ts不能解析*.vue解决办法:

方式一、在tsconfig.json中配置 "compilerOptions": {.... "allowJs": true, }

方式二、找到vite-env.d.ts文件或者env.d.ts文件,添加如下代码

TypeScript 复制代码
declare module '*.vue' {
  import type { DefineComponent } from 'vue';

  const component: DefineComponent<{}, {}, any>;
  export default component;
}
相关推荐
Trae1ounG5 分钟前
Vue Iframe
前端·javascript·vue.js
爱上妖精的尾巴1 小时前
8-1 WPS JS宏 String.raw等关于字符串的3种引用方式
前端·javascript·vue.js·wps·js宏·jsa
史丹利复合田1 小时前
【无标题】vscode远程连接,服务器端配置
ide·vscode·编辑器
web打印社区1 小时前
vue页面打印:printjs实现与进阶方案推荐
前端·javascript·vue.js·electron·html
daols882 小时前
vue2 甘特图 vxe-gantt 一行渲染多个子任务的配置
vue.js·甘特图·vxe-table
gusijin3 小时前
解决idea启动报错java: OutOfMemoryError: insufficient memory
java·ide·intellij-idea
吨~吨~吨~3 小时前
解决 IntelliJ IDEA 运行时“命令行过长”问题:使用 JAR
java·ide·intellij-idea
HAPPY酷3 小时前
为啥双击 .sln 文件即可在 Visual Studio 中加载整个解决方案
ide·visual studio
summer_du3 小时前
IDEA插件下载缓慢,如何解决?
java·ide·intellij-idea
pas1363 小时前
39-mini-vue 实现解析 text 功能
前端·javascript·vue.js