vue-cli 依赖升级后就运行就报 "jsx", "flow", "typescript".错误, 这种情况要怎么解决?
"devDependencies": {
"@babel/core": "^7.16.12",
"@babel/eslint-parser": "^7.16.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@umijs/fabric": "^2.10.1",
"@vue/cli-plugin-babel": "^5.0.0",
"@vue/cli-plugin-eslint": "^5.0.0",
"@vue/cli-plugin-pwa": "^5.0.0",
"@vue/cli-plugin-router": "^5.0.0",
"@vue/cli-plugin-vuex": "^5.0.0",
"@vue/cli-service": "^5.0.0",
"@vue/compiler-sfc": "~3.2.29",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-plugin-import": "^1.13.3",
"eslint": "^7.20.0",
"eslint-plugin-linestyle": "^1.0.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.20.0",
"less": "^4.0.0",
"less-loader": "^6.2.0",
"lint-staged": "^12.3.1",
"prettier": "^2.5.1",
"style-resources-loader": "^1.5.0",
"vue-cli-plugin-style-resources-loader": "^0.1.5"
}
.eslintrc.js
{
root: true,
env: {
browser: true,
es2021: true,
},
extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/prettier"],
// parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 12,
parser: "@babel/eslint-parser",
requireConfigFile: false,
sourceType: "module",
allowImportExportEverywhere: true,
ecmaFeatures: {
jsx: true,
},
},
}
我重新拉取项目依赖后就报
ERROR in ./src/views/table/index.vue?vue&type=script&lang=js (./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/table/index.vue?vue&type=script&lang=js)
Module Error (from ./node_modules/vue-loader/dist/index.js):
[vue/compiler-sfc] This experimental syntax requires enabling one of the following parser plugin(s): "jsx", "flow", "typescript". (37:12)
网上的修改方法都试过,都不行,不知道有没有什么好的解决方法
回复
1个回答
test
2024-07-01
如果你在 /src/views/table/index.vue
这个组件中使用了 jsx
,那么需要 <script setup lang="jsx">
这样声明。
回复
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容