本文介绍了无需重新加载页面即可反应路由器更改网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用 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.
github/reactjs/react-router/issues/3411
更多推荐
无需重新加载页面即可反应路由器更改网址
发布评论