为了账号安全,请及时绑定邮箱和手机立即绑定

react-router4 Route中的children属性作用是什么

react-router4 Route中的children属性作用是什么

胡子哥哥 2019-03-07 17:15:26
看了官方文档,没想明白是干什么的,和Route的render属性有什么区别?const OldSchoolMenuLink = ({ label, to, activeOnlyWhenExact }) => (    <Route path={to} exact={activeOnlyWhenExact} children={({match}) => (        <div className={match ? 'active' : ''}>            {match ? '>' : ''}<Link to={to}>{label}</Link>        </div>    )}></Route>);
查看完整描述

2 回答

?
MMMHUHU

TA贡献1834条经验 获得超8个赞

找到官方解释了

Sometimes you need to render whether the path matches the location or not. In these cases, you can use the function children prop. It works exactly like render except that it gets called whether there is a match or not.


查看完整回答
反对 回复 2019-03-28
  • 2 回答
  • 0 关注
  • 589 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号