从官方例子试了下, 组件props
只接收到了router默认注入的props,定义的如何注入,比如我想注入一个test
字段?
ps: 想增加个props做路由权限校验
###很简单啊。修改一下下面两处:
function RouteWithSubRoutes(route) {
return (
<Route
path={route.path}
render={props => (
// pass the sub-routes down to keep nesting
<route.component {...props} routes={route.routes} test={route.test} />
)}
/>
);
}
function Sandwiches(props) {
console.log(props.test);
return <h2>Sandwiches</h2>;
}
###看错问题了,不好意思。