react-router實現跳轉傳值的方法示例

轉自:https://www.jb51.net/article/114837.htm

1.引入包 

import {hashHistory} from 'React-router'

2.跳轉傳值:

handleClick = (value) => {
 hashHistory.push({
  pathname: 'message/detailMessage',
  query: {
   title:value.title,
   time:value.time,
   text:value.text
  },
 })
}

3.接收值:

console.info(this.props.location.query.title)
console.info(this.props.location.query.time)
console.info(this.props.location.query.text)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章