简体   繁体   English

反应:带参数的路由器链接不起作用

[英]React: router link with param not working

在此处输入图片说明

My problem is passing ${file.id} to link, but when I navigate to that link, I only receive like this: 我的问题是将$ {file.id}传递给链接,但是当我导航到该链接时,只会收到如下内容: 在此处输入图片说明

the ${file.id} is not get correct value. $ {file.id}的值不正确。 But when I inspect the key of row, it can render correct. 但是,当我检查row键时,它可以呈现正确的图像。

在此处输入图片说明 What are my mising? 我在想什么

Thanks 谢谢

You are using the wrong quotes. 您使用了错误的引号。 String interpolation is not possible with single quotes or doublequotes. 单引号或双引号不能进行字符串插值。 You have to use the backtick ` 您必须使用反引号`

So 所以

<Link to={'api/admin/blobManager/${file.id}'} />

should instead be 相反应该是

<Link to={`api/admin/blobManager/${file.id}`} />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM