react-router 4.0 学习笔记
生活随笔
收集整理的這篇文章主要介紹了
react-router 4.0 学习笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
1、安裝react-router-dom?
2、頁面上要使用的時候要引入
import {BrowserRouter as Router,Route,Link } from 'react-router-dom'3、使用的時候要在外層包一個<Router>
4、param
在路徑上如果帶有/:id類似這種的,要取值的時候,match.params.id取值
? ?
5、重定向(Redirects)
<Redirect to={{pathname: '/yuer/index' }}/>
6、通過match可以獲得相應的參數值
7、URL的查詢字符串(/test?id=111)
使用this.props.location.query.id獲取
8、NavLink
用于設置導航鏈接
(1)可以通過直接設置樣式來設置
(2)可以通過控制class來設置
9、返回上一頁
this.props.history.goBack();
10、指定跳轉頁面
this.props.history.push(" ")
?
?
?
?
轉載于:https://www.cnblogs.com/qzccl/p/7852915.html
總結
以上是生活随笔為你收集整理的react-router 4.0 学习笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OSI七层模型与TCP/IP五层模型详解
- 下一篇: 笔记41 Spring Web Flow