javascript - 解析错误:意外的令牌,预期的“...”
问题描述
我在组件中有这个带有模板文字的代码,我从 ESLint 得到解析错误。我尝试使用 @babel/eslint-parser 但它没有帮助。还有这个解析错误:Unexpected token, expected "..." I have '...' expected.ts(1005)
import React from "react";
import { Link } from "react-router-dom";
import logo from "../../images/logo_cl.png";
function Comptetition({ competition }) {
return (
<Link to {`/competitions/${competition.id}`}>
<li className="complist__item">
<img className="complist__item-image" src={logo} alt="item" />
<p className="complist__item-name">{competition.name}</p>
<p className="complist__item-country">{competition.area.name}</p>
</li>
</Link>
);
}
export default Comptetition;
我的 .eslintrc.json 看起来像这样:
{
"env": {
"browser": true,
"jest": true,
"es6": true,
"node": true
},
"plugins": [
"import",
"react"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"airbnb-base",
"plugin:prettier/recommended"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"requireConfigFile": false,
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"babelOptions": {
"presets": [
"@babel/preset-react"
]
}
},
"rules": {
"semi": "error",
"no-console": "warn",
"no-eval": "error",
"import/first": "error",
"prefer-template": 1,
"no-param-reassign": [
2,
{
"props": false
}
]
}
}
我已经阅读了很多信息,但无法在 VScode 中解决此错误
解决方案
您忘记=
添加to
to={`/competitions/${competition.id}`}
推荐阅读
- python - django 身份验证 URL 的默认命名空间是什么?
- python - 如何在pyodbc中同时在n个游标上并行运行n个进程?
- php - PHP 邮件未到达 Amazon EC2 上的目的地
- javascript - 如何关闭在 React + Redux 应用程序中单击外部的模态窗口?
- c# - 当我们遍历文件时,如何动态创建文件夹并将文件放入其中?
- r - sf 对象未正确覆盖在 r 中的 ggmap 层上
- video - 连接视频音频/视频不同步:非单调 TDS 输出
- python - 列出目录中的某些 Python 文件
- javascript - 正则表达式查找字符串之间的连接字符
- php - 仅发送部分标头(预加载/预取)