2016-01-20 47 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}/>