react-router刷新时The requested URL was not found on this server.

路由定义如下

let routes = (
    <Route handler={App}>
        <Route path="/" component={App}>
            <Route path="/search/:id/:page" component={Search} />
        </Route>
    </Route>
);

其他功能都对,就是刷新还有直接打开http://localhost/search/66/1的时候找不到url。必须先进http://localhost在跳转到/search/66/1。

url怎么没有井号呢?

阅读 5.3k
2 个回答

你上面的那个问题还没碰到过

至于没有# ,我想到的是可能与history有关,现在我配置的都是 history={browserHistory},如果是hashHistory 的应该才有# ,具体可以看看官方介绍
这是中文文档 但是中文文档后期的维护比较慢,很多新的东西都没有跟新

同问,我目前是,在服务端配置跳转回首页
{

    route : '/*',
    method : 'all',
    callback: function *(){
        this.redirect('/');
    }

}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题