反应参数 - 警告:<a> 标签上的未知道具"参数".从元素中删除此道具



我正在尝试使用反应路由器制作配置文件页面,Warning: Unknown prop params on <a> tag. Remove this prop from the element.我正在尝试将参数传递给路由,以便每个用户都有自己加载其内容的唯一页面。 我得到的解决方案是从 2015 年开始的,我不知道他们是否删除了它。 是否有将参数传递到路由路径的新版本/更新版本,或者我做错了什么?

<Route component={userProfile} path="/user/:userId" userIdentity={Meteor.userId()}/>
<p><Link to="/userProfile/:userId" params={{userId: Meteor.userId()}}>My Profile</Link></p>

你只是想把userId作为参数传递吗?您可以在 Link'd 组件中访问它<UserProfile />通过调用this.props.match.params.userId并从那里开始。

你想这样做

<Link to={`user/${Meteor.userId()}`} />

即使用用户 id 构建要链接到的静态路由。没有什么比这更复杂的了。

最新更新