1. 引入包
import {hashHistory} from 'react-router'
2. 跳转传值
参数放在query对象里面
Search = () => {
hashHistory.push({
pathname: '/borrow/searchPage',
query: {category: this.state.category},
});
}
使用
console.log(this.props.location.query.category)
本文介绍如何在 React 应用中使用 react-router 进行页面跳转并传递参数,具体展示了如何通过 query 对象携带 category 参数进行跳转,并在目标页面中获取该参数。
1. 引入包
import {hashHistory} from 'react-router'
2. 跳转传值
参数放在query对象里面
Search = () => {
hashHistory.push({
pathname: '/borrow/searchPage',
query: {category: this.state.category},
});
}
使用
console.log(this.props.location.query.category)
1479

被折叠的 条评论
为什么被折叠?