简体   繁体   English

有什么更干净的方法来触发React Route更改吗?

[英]Any cleaner way to trigger React Route change?

I am pretty new to React-Router, I wonder if there is a simple way to change Route, some concept like state in Angular UI Router. 我对React-Router还是很陌生,我想知道是否有一种简单的方法来更改Route,例如Angular UI Router中的状态之类的概念。 From the React Router official tutorial : 来自React Router官方教程:

https://github.com/reactjs/react-router-tutorial/tree/master/lessons/12-navigating https://github.com/reactjs/react-router-tutorial/tree/master/lessons/12-navigating

My understanding is: I have to manually change the url to trigger route change. 我的理解是:我必须手动更改URL才能触发路由更改。

What exactly are you trying to achieve? 您到底想达到什么目的? Did you take at look at the react-router Link component? 您是否看过react-router Link组件?

Perhaps the most used component in your app is Link. 您的应用中最常用的组件也许是链接。 Its almost identical to the <a/> tag you're used to except that its aware of the Router it was rendered in. 它与您习惯的<a/>标记几乎相同,除了它知道在其中渲染了Router。

React-Router Tutorial / Lesson 3: Navigating with Link React-Router教程/第3课:使用链接导航

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM