【发布时间】:2019-08-24 04:39:41
【问题描述】:
您好,我希望它在#/ 可以访问但#/ipb 可以访问时将InstrumentPage 渲染为没有道具,但当ipb 作为道具实体进行访问时。但它不起作用。
render() {
return (<React.Fragment>
<HashRouter>
<Switch>
<Route path='/' render={(props) => <InstrumentPage {...props} />}/>
{Object.keys(AppConfig).forEach((property) =>
<Route path={property} render={(props) => <InstrumentPage {...props} entity={property} />} />)
}
</Switch>
</HashRouter>
</React.Fragment>);
}
应用配置
const AppConfig = {
pb: {
header: 'PBHeader',
body: 'PBBody',
},
ipb: {
header: 'IPBHeader',
body: 'IPBBody',
},
};
export default AppConfig;
【问题讨论】:
-
forEach没有返回任何内容,您的意思是map在数组上吗?
标签: javascript reactjs react-router react-router-dom