简体   繁体   English

反应路由器路径的不同组件

[英]React router path different components

在此处输入图片说明

How can we set footerNew if path is example2 and footer if we have path example. 如果path为example2,如何设置footerNew;如果有path示例,如何设置footer。 How can we change component with different path . 我们如何改变路径不同的组件。 I know this could have been done with the path mixing but that has been deprecated 我知道这可以通过混合路径来完成,但是已经过时了

The only diff you have between your routes is the pathname. 路径之间唯一的区别就是路径名。 So : 因此:

<div className="...">
    {props.context.router.getCurrentPathname() === '/example' ? <Footer /> : </FooterNew />}
</div>

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

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