1. 程式人生 > >react-router跳轉傳值

react-router跳轉傳值

1.引入包 

import {hashHistory} from ‘React-router’

2.跳轉傳值

    handleClick = (value) => {
        hashHistory.push({
            pathname: 'message/detailMessage',
            query: {
                title:value.title,
                time:value.time,
                text:value.text
            },
        })
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

3.接收值

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