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),那么这个配置应该是必要的。

相关推荐
wanzhong233316 小时前
开发日记13-响应式变量
开发语言·前端·javascript·vue
wanzhong233316 小时前
开发日记14-vite配置多环境
服务器·前端·vue
刘一说1 天前
Vue3 组合式 API(Composition API):逻辑复用的革命性实践
vue.js·vue
天天打码1 天前
Svelte-无虚拟DOM、极致性能的现代高性能Web开发框架!
前端·node.js·vue·svelte
LXMXHJ2 天前
项目之html+javaScript
java·vue
期货资管源码2 天前
智星期货资管子账户软件pc端开发技术栈的选择
c语言·数据结构·c++·vue
@二十六2 天前
表格行拖拽排序
vue·react·表格拖拽
jay神2 天前
基于Java的水果网上订购平台
java·mysql·vue·springboot·计算机毕业设计
午安~婉3 天前
整理知识点
前端·javascript·vue
Shi_haoliu4 天前
SolidTime 在 Rocky Linux 9.5 上的完整部署流程
linux·运维·nginx·postgresql·vue·php·laravel