博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[React Router v4] Use the React Router v4 Link Component for Navigation Between Routes
阅读量:6576 次
发布时间:2019-06-24

本文共 939 字,大约阅读时间需要 3 分钟。

If you’ve created several Routes within your application, you will also want to be able to navigate between them. React Router supplies a Link component that you will use to make this happen.

Import Link:

import {    BrowserRouter as Router,    Route, Link} from 'react-router-dom';

 

Add Nav section to the page

const Nav = () => (  
);

There are two ways to nav to another page.

 

1. to="/about"

2. to={

{pathname: '/contact'}}

 

Here the 'replace' keyword able to help modify pushHistory. Once you use 'replace' it will replace previous state to current state, instead of add one state.

For example.

Current history: ['/', '/about', '/contact'], in the normal case, you hit the 'Back' button in your browser it will bring you back to '/about'.

But once you use 'replace', it will replace ['/', '/about'] to ['/', '/contact']. So you when hit 'Back' button , you will back to '/'.

转载地址:http://owgjo.baihongyu.com/

你可能感兴趣的文章
堆排序
查看>>
解决PyScripter中文乱码问题
查看>>
Python: 分数运算
查看>>
信息隐藏技术与应用期末复习
查看>>
ulimit命令学习
查看>>
js - 预加载+监听图片资源加载制作进度条
查看>>
[BZOJ1934][Shoi2007]Vote 善意的投票[最小割]
查看>>
sort()排序
查看>>
Windows IO 性能简单测试
查看>>
HDU-1796 How many integers can you find 容斥定理
查看>>
css display&&hidden
查看>>
不使用border-radius,实现一个可复用的高度和宽度都自适应的圆角矩形
查看>>
平衡二叉树——Balance Binary Sort Tree 设计与实现
查看>>
https
查看>>
js动态加载css文件和js文件的方法
查看>>
HTML中的table和div
查看>>
SqlServer整库备份还原脚本
查看>>
使用Github发布自己的网站
查看>>
2019-04-28 Mybatis generator逆向工程生成的Example代码分析
查看>>
使用SQL Server Analysis Services数据挖掘的关联规则实现商品推荐功能(七)
查看>>