2016-02-12 91 views
1

我有一個反應的應用程序使用反應路由器。反應路由器和Phonegap - 第一頁未找到

當我將它捆綁到phonegap並使用iPhone上的phonegap應用程序連接到它時,我直接進入我的404(未找到)頁面。

從我的404頁的我是那麼能夠導航到我的應用程序的其餘部分(如果我包括頁面上的菜單)

下面是我的反應路由器的代碼,有沒有人遇到過類似的問題?

ReactDOM.render(
    <Router history={browserHistory}> 
     <Route path="/" component={App}> 
      <IndexRoute component={Directory} /> 
      <Route path="feed" component={Feed} /> 
      <Route path="page"> 
       <Route path="about" component={About}/> 
      </Route> 
      <Route path="*" component={Four04Page}/> 
     </Route> 
    </Router>, 
    document.getElementById('app') 
); 

回答

1

我最近也有類似的問題,並能夠通過使用routerHistory而不是默認browserHistory來解決它。

這是如何具體實現取決於你在哪個版本的React路由器。

我跟着V2.0遷移指南,以實現它:

https://github.com/reactjs/react-router/blob/095ed6cf51d3c4755f13b428182e8ec2df593277/upgrade-guides/v2.0.0.md#using-custom-histories

+0

我沒有花費太多時間到看爲什麼這個作品,但它解決了我的問題。非常感謝!! – user195257