Link & Redirect
【Link】
Link标签,用于实现React-Router功能的跳转。(意思是就不要使用a标签了)
1)to:string,指明要跳转的path。
import { Link } from 'react-router-dom'
<Link to="/about">About</Link>
2)Link的牛逼之处,就是可以拼完整url。
to:object,指明要跳转的path、query、state。
<Link to={{
pathname: '/courses',
search: '?sort=name',
hash: '#the-hash',
state: { fromDashboard: true }
}}/>
3)replace,When true, clicking the link will replace the current entry in the history stack instead of adding a new one.
<Link to="/courses" replace />
【Redirect】
Redict会直接跳转到新地址。
import { Route, Redirect } from 'react-router'
<Route exact path="/" render={() => (
loggedIn ? (
<Redirect to="/dashboard"/>
) : (
<PublicHomePage/>
)
)}/>
参考:https://reacttraining.com/react-router/web/guides/quick-start
Link & Redirect的更多相关文章
- javascript,HTML,PHP,ASP做301跳转代码 SEO优化设置
URL HTTP Redirection URL http redirection is an automatic URL change operation from one URL to anoth ...
- php防盗链,php ci在control里面控制除了自己站内的链接点击跳转,其他来源的都跳到站内页面
php防盗链,php ci在control里面控制除了自己站内的链接点击跳转,其他来源的都跳到站内页面 $route['jump/(:any)/(:any)'] = "index/jump/ ...
- react-router详细解释
react-router的理解 react的一个插件库,专门用来实现一个SPA应用(单页Web应用(single page web application,SPA)整个应用只有一个完整的页面,点击页面 ...
- react 路由导航栏 withRouter
codesandbox https://codesandbox.io/s/9l6prnyxjy app.js import React, { Component, Fragment } from &q ...
- react-router 4.0(三)根据当前url显示导航
import React, { PropTypes } from 'react' import ReactDOM from 'react-dom' import { HashRouter, Route ...
- React-router4 第八篇 ReactCSSTransitionGroup 动画转换
https://reacttraining.com/react-router/web/example/animated-transitions 动画转换这么高级,其实是又引入了一个组件,没什么特别, ...
- React中路由的基本使用
现在我们来搞一搞React中的路由吧,别问我为什么这木喜欢用搞这个字,因为它比较深奥. 注意下面我们使用的是React-Router-DOM React中的路由基本使用还是满简单的,零碎的小东西有点多 ...
- React-router4 第三篇 BasicURL ParametersRedirects (Auth) 谷歌翻译:重定向
依旧是地址 https://reacttraining.com/react-router/web/example/auth-workflow 上来一步走 先导入模块 import React, { P ...
- wordpress必装的插件 wp最常用的十个插件
wordpress是世界上著名的博客系统,简称wp.一般新安装完wordpress以后,往往需要首先安装一些插件,这样才可以使用wordpress的更多功能.wp最常用的十个插件有哪些呢,可能根据每个 ...
随机推荐
- 自动化脚本编写环境部署_win7(RF)
第一步 安装Python并设置环境变量 1.安装python: python下载地址https://www.python.org/,建议用2.7.x版本 2.设置环境变量: 方法如下所示 第二步 安 ...
- 2.HTML文件中<!DOCTYPE html>的作用
<!DOCTYPE> 声明位于文档中的最前面的位置,处于 <html> 标签之前.此标签可告知浏 览器文档使用哪种 HTML 或 XHTML 规范.(重点:告诉浏览器按照何种规 ...
- maven 插件深入了解
http://www.infoq.com/cn/news/2011/04/xxb-maven-7-plugin http://www.infoq.com/cn/news/2011/05/xxb-mav ...
- VC中明明已经添加了头文件却还提示未定义的问题
我在VS中编译程序遇到这个错误:error C3861: 'ReadDirectoryChangesW': identifier not found, even with argument-depen ...
- DataSnap Server 客户端调用 异常
No peer with the interface with guid {9BB0BE5C-9D9E-485E-803D-999645CE1B8F} has been registered.
- delphi treeview checkbox
delphi treeview checkbox 最新版Berlin还没有带checkbox的treeview?
- WeakReference与SoftReference
WeakReference与SoftReference都可以用来保存对象的实例引用,这两个类与垃圾回收有关. WeakReference是弱引用,其中保存的对象实例可以被GC回收掉.这个类通常用于在某 ...
- day29-序列化 json、pickle、shelve
1.pickle和JSON序列化 如果我们想用文本文件保存一个 Python 对象怎么操作?这里就涉及到序列化的问题,序列化指的是将原本的字典.列表等内容转换成一个字符串的过程. 2.为什么要使用序列 ...
- java配置slf4j日志系统
首先要导入的包: import: 每个类中加入下面,其中 RdiFtpDownload.class 是当前的类名.class 然后就可以打日志了: 配置 log4j.properties log4j. ...
- win10家庭版升级专业版的两种方法和密钥
win10家庭版升级专业版密钥:VK7JG-NPHTM-C97JM-9MPGT-3V66T4N7JM-CV98F-WY9XX-9D8CF-369TT FMPND-XFTD4-67FJC-HDR8C-3 ...