vue3.0 + ts + eslint报错:error Parsing error: ‘>‘ expected

eslint报错

这里加上对应的 eslint配置即可:

复制代码
parser: 'vue-eslint-parser',
parserOptions: {
  parser: "@typescript-eslint/parser",
  ecmaVersion: 2020,
  sourceType: 'module',
}

具体如下:

复制代码
module.exports = {
  parser: 'vue-eslint-parser',
  parserOptions: {
 	parser: "@typescript-eslint/parser",
    ecmaVersion: 2020,
    sourceType: 'module',
  },
  extends: [
    // 添加 ESLint 扩展规则
    'plugin:vue/vue3-recommended',
    // 添加其他 ESLint 扩展规则
  ],
  rules: {
    // 覆盖或添加自定义 ESLint 规则
  },
};

这个配置是在ESLint中指定Vue文件的解析器。在.eslintrc.js或.eslintrc.ts文件中,"parser": "vue-eslint-parser"表示ESLint应该使用vue-eslint-parser来解析.vue文件。这是因为.vue文件是由HTML、CSS和JavaScript(或TypeScript)组成的单文件组件,而ESLint默认不理解这种文件格式。

vue-eslint-parser是一个独立的npm包,它提供了一个解析器,可以让ESLint理解Vue文件的语法。

如果你在使用Vue 3.0和TypeScript,并且已经正确安装了vue-eslint-parser和所需的Vue ESLint插件(如@vue/eslint-plugin-vue),那么这个配置应该是必要的。

相关推荐
百锦再1 天前
Vue中对象赋值问题:对象引用被保留,仅部分属性被覆盖
前端·javascript·vue.js·vue·web·reactive·ref
一笑code1 天前
vue/微信小程序/h5 实现react的boundary
微信小程序·vue·react
eric*16881 天前
尚硅谷张天禹老师课程配套笔记
前端·vue.js·笔记·vue·尚硅谷·张天禹·尚硅谷张天禹
喜欢敲代码的程序员2 天前
SpringBoot+Mybatis+MySQL+Vue+ElementUI前后端分离版:项目搭建(一)
spring boot·mysql·elementui·vue·mybatis
海的诗篇_2 天前
前端开发面试题总结-原生小程序部分
前端·javascript·面试·小程序·vue·html
sunbyte2 天前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | DragNDrop(拖拽占用组件)
前端·javascript·css·vue.js·vue
奋飛2 天前
TypeScript系列:第六篇 - 编写高质量的TS类型
javascript·typescript·ts·declare·.d.ts
skyymrj12 天前
Vue3 + Tailwind CSS 后台管理系统教程
前端·css·vue
程序猿小D12 天前
[附源码+数据库+毕业论文]基于Spring+MyBatis+MySQL+Maven+Vue实现的校园二手交易平台管理系统,推荐!
java·数据库·mysql·spring·vue·毕业设计·校园二手交易平台
伍哥的传说12 天前
react gsap动画库使用详解之text文本动画
前端·vue.js·react.js·前端框架·vue·html5·动画