我正在尝试利用urlpatterns = [
path(r'reports/<int:game_id>/)', views.get_pdf_report, name='get_pdf_report'),
path(r'teams/<int:team_id>/)', views.get_team_formation, name='get_team_formation'),
path(r'game-instance/<int:game_id>/)', views.get_match_instance, name='get_match_instance'),
url(r'^api-auth/', include('rest_framework.urls')),
url(r'^', include(router.urls))
]
来移动而不更改URL地址,因为我的应用程序将在iframe中呈现。但是,当我推送到createMemoryHistory
时,似乎更新了我的URL。任何提示将不胜感激!
history
答案 0 :(得分:1)
在使用MemoryHistory时,应将历史对象传递到路由器,并在导入创建的历史记录后直接使用它,例如
App.js
import history from './history/history';
...
<Router history={history}>
<Route
path={'/'}
render={(props) => <Component {...props}/>}
/>
</Router>
component.js
import history from './history/history';
...
function handleClick() {
history.push('somePath'); // this updates my url to be url.com/somePath
}
return (<Button onClick={() => handleClick()}>);
答案 1 :(得分:0)
解决了该问题,我没有正确导入一些东西。最后仍然停留在createMemoryHistory
而不是createBrowserHistory