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;
}
相关推荐
未来之窗软件服务24 分钟前
声音分离人声和配乐-从头设计数字生命第4课——仙盟创梦IDE
ide·仙盟创梦ide·数字生命
躲在云朵里`29 分钟前
IDEA搭建环境的五种方式
java·ide·intellij-idea
Zhuai-行淮1 小时前
vscode和git 踩坑
ide·git·vscode
乌夷1 小时前
使用spring boot vue 上传mp4转码为dash并播放
vue.js·spring boot·dash
Percep_gan2 小时前
解决重装idea后破解jerbel的问题
java·ide·intellij-idea
苹果酱05673 小时前
2020-06-23 暑期学习日更计划(机器学习入门之路(资源汇总)+概率论)
java·vue.js·spring boot·mysql·课程设计
Deepsleep.3 小时前
react和vue的区别之一
javascript·vue.js·react.js
zqlcoding3 小时前
使用el-table表格动态渲染表头数据之后,导致设置fixed的列渲染出现问题
前端·javascript·vue.js
爱吃的强哥3 小时前
vue3 使用 vite 管理多个项目,实现各子项目独立运行,独立打包
前端·javascript·vue.js
涵信4 小时前
第十节:性能优化高频题-虚拟DOM与Diff算法优化
javascript·vue.js·性能优化