我有一个map函数我尝试将obj.id连接到react-router的Link组件。它不会像这样工作吗?
<Link to="/item/edit/"{obj._id}>Edit</Link>
我甚至尝试过
<Link to=`/item/edit/${obj._id}`>Edit</Link>
没有运气。帮助
答案 0 :(得分:0)
您需要在花括号之间传递JavaScript。请参阅有关JavaScript表达式的文档:https://facebook.github.io/react/docs/jsx-in-depth.html#javascript-expressions
要么像这样:
if let queryItems = components?.queryItems {
// process the query items here...
let param1 = valueFrom(queryItems:queryItems, key:"item")
print("***************=> GOT IT ", param1)
}
或者像这样:
<Link to={"/item/edit/" + obj._id}>Edit</link>