2016-01-20 97 views
0

我尝试使用下面的代码导航到一个页面上的按钮,点击:阵营路由器不会取代以前的页面内容

this.props.history.pushState(null, "page2"); 

它改变了在地址栏中的网址,并显示我TargetURL中对内容当前页面本身,而不是隐藏前一页的内容。

下面是我的路由器代码:

const routes = (
<Router history={createBrowserHistory(historyOptions)}> 
    <Route path='/' component={BaseLayout}> 
     <IndexRoute component={Home}/> 
     <Route path="/page2" component={Page2}/> 
    </Route> 
</Router> 
); 

我使用的反应路由器版本:1.0.0。我该如何解决这个问题?

回答

-1

尝试删除斜杠。 <Route path="page2" component={Page2}/>