1、routerRedux方式(刷新页面,参数丢失)
import { routerRedux } from 'dva/router';//页面跳转+参数goOrder (record){ this.props.dispatch(routerRedux.push({ pathname: '/giveData/queryOrder', params: record.userId })) } <a className={styles.oprLink} onClick={()=>this.goOrder(record)}>查订单</a>
参数接收: 使用this.props.location.params接收值。
2、link方式
import { Link } from 'react-router-dom';// 或者 import { Link } from 'dva/router'; <Link to={{pathname:'/user',query:id}}>添加用户</Link>
参数接收:使用v2,v3的 this.props.location.query或者v4的this.props.location.search接收值。
3、router.push方式(刷新页面,参数不丢失)
import router from 'umi/router' // 法一// 先定义好路由router.push(`/test/search/${param1}/${param2}`); // 获取方式const { match: { params } } = this.props;cosnt param1 = params.param1;cosnt param2 = params.param2; // 法二router.push({ pathname: '/test/search/', query: { param1: param1, param2: param2, },}); // 获取方式const { location: { query } } = this.props;cosnt param1 = query.param1;cosnt param2 = query.param2;
原文:https://blog.csdn.net/qq_25252769/article/details/79958487