无需重新加载页面即可反应路由器更改网址

问题描述:

当我使用 react-router 0.13.3 时,没问题:我正在更改 url 并且没有重新加载发生转换.

When I was using react-router 0.13.3, it was ok: i was changing url and transition without reload was happening.

现在,在 react-router 2.0 中,如果我手动更改 url,我的应用将完全重新加载,而不是简单的重定向.我该如何解决?

Now, in react-router 2.0 if I'm changing url manually, my app gets reloaded entirely instead of simple redirect. How do i fix it?

我想用这个:

<a href="/routename">link</a>

改为:

<Link to="/routename">link</Link>

在少数特殊情况下.

import {Router, Route, IndexRoute} from "react-router";
import App from './components/App';
import FrontPage from './components/frontPage/FrontPage';
import User from './components/user/User';
module.exports = (
    <Router>
        <Route path="/" component={App}>
            <IndexRoute component={FrontPage}/>
            <Route path="/user/:userid" component={User}/>
        </Route>
    </Router>
);

没有解决方案.我们可以onClick 脚本或Link.

There is no solution. We can either onClick script or Link.

https://github.com/reactjs/react-router/issues/3411