我正在尝试使用以下路由配置显示嵌套在父视图中的表单:
const routes = (
<Router history={history}>
<Route path='/' component={App}>
<IndexRoute component={Landing}/>
<Route path='applications' component={Applications}>
<Route path='/new' component={ApplicationForm}/>
</Route>
</Route>
</Router>
);
访问/applications
时,我会渲染我的Applications
组件
class Applications extends Component {
renderContent () {
return (
<div className="dashboard">
{this.props.children}
</div>
);
}
render () {
return (
<DashboardLayout
content={this.renderContent()}
{...this.props}/>
);
};
}
但出于某种原因,Applications
组件也会呈现为this.props.children
,但没有初始渲染的道具