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

编程入门 行业动态 更新时间:2024-10-26 17:22:17
本文介绍了无需重新加载页面即可反应路由器更改网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我使用 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

更多推荐

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

本文发布于:2023-10-31 17:22:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546763.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由器   加载   页面   网址

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!