在这里插入图片描述
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),那么这个配置应该是必要的。

更多推荐