【发布时间】:2018-08-28 17:29:37
【问题描述】:
当用户单击点击区域时,我试图传递所选的帐户 ID。
<Link to="/account" id={1234}>
但是,在我的 Account 组件上,这个“to”将我们带到:
<Route path="/account" component={Account}/>
我得到了未定义。
export default class Account extends Component {
constructor(props) {
super(props);
alert(props.id);
有没有办法使用链接将道具传递给我的组件?
【问题讨论】:
-
需要你添加更多代码,这样我才能看到我们应该如何将 id 传递给 Account
标签: reactjs react-router