【问题标题】:why i am getting error for this one like Unexpected template string expression no-template-curly-in-string为什么我收到错误,例如 Unexpected template string expression no-template-curly-in-string
【发布时间】:2021-08-26 04:17:04
【问题描述】:
 <Card className='my-3 p-3 rounded'>
  <a href={'/product/${product._id}'}>
    <Card.Img src={product.image} variant='top' />
  </a>
</Card>

我在这里发布我的代码我在运行 npm start 时遇到错误 意外的模板字符串表达式 no-template-curly-in-string

【问题讨论】:

标签: javascript html visual-studio-code vscode-settings react-bootstrap-typeahead


【解决方案1】:

您应该在 &lt;a&gt; 标记内的 href 中将引号 (') 替换为反引号 (`),如下所示。

之前:

&lt;a href={'/product/${product._id}'}&gt;

之后:

&lt;a href={`/product/${product._id}`}&gt;

这里是link eslint 文档页面以获取更多信息。

【讨论】:

  • 是的,我在发布问题后解决了它
猜你喜欢
  • 2020-08-26
  • 1970-01-01
  • 1970-01-01
  • 2021-12-16
  • 1970-01-01
  • 2023-02-02
  • 1970-01-01
  • 2014-12-25
  • 2023-02-20
相关资源
最近更新 更多