当我执行以下操作时:
routeToCreateCreatives() {
this.props.pushState(null, 'create');
}
它改变了网址: http://localhost:3000/campaign/SLUG/creatives/create
但是我收到了这个警告:
Warning: Location "creatives/create" did not match any routes
奇怪的是,当我刷新页面或导航到URL时,它会加载。
以下是我的嵌套路线:
<Route path="/campaign/:campaignId" component={Campaign}>
<IndexRoute component={CampaignDashboard} />
<Route path="dashboard" component={CampaignDashboard}/>
<Route path="creatives" component={Creatives}/>
<Route path="creatives/create" component={CreativesCreate}/>
</Route>
最后,如果我使用如下所示的绝对路径,则链接有效。使用pushState时遇到一些问题:campaignId slug。
pushState(null, `/campaign/${campaign.id}/creatives`);