Reactjs React路由器v4将参数替换为<;链接/>;

Reactjs React路由器v4将参数替换为<;链接/>;,reactjs,react-router,Reactjs,React Router,我的仪表板组件呈现一个名为后命令的共享组件,该组件呈现一个用包装的列表,当列表打开时,单击页面导航到配置文件组件,在该组件上我还有后命令 现在,如果我单击我的Profile组件上的一个列表,url参数就会像这样堆叠起来 您需要手动替换url的最后一部分,因为您需要重新使用它 const splitUrl = match.url.split('/'); // Split into array splitUrl.splice(-1, 1, i.comment_from_id); // Replace

我的
仪表板
组件呈现一个名为
后命令
的共享组件,该组件呈现一个用
包装的列表,当列表打开时,单击页面导航到
配置文件
组件,在该组件上我还有
后命令

现在,如果我单击我的
Profile
组件上的一个列表,url参数就会像这样堆叠起来


您需要手动替换url的最后一部分,因为您需要重新使用它

const splitUrl = match.url.split('/'); // Split into array
splitUrl.splice(-1, 1, i.comment_from_id); // Replace the last part with the new id
return ( 
  <Link replace to={splitUrl.join('/')}> // Recreate the correct url
  // ...
const splitUrl=match.url.split(“/”);//拆分为数组
splitUrl.splice(-1,1,i.comment_from_id);//用新id替换最后一个零件
报税表(
//重新创建正确的url
// ...
const splitUrl = match.url.split('/'); // Split into array
splitUrl.splice(-1, 1, i.comment_from_id); // Replace the last part with the new id
return ( 
  <Link replace to={splitUrl.join('/')}> // Recreate the correct url
  // ...