ant design Pro 组件间通过路由(routerRedux)方式传值

539 阅读1分钟

 1、引入  routerRedux

import { routerRedux } from 'dva/router'

2、在Table 组件中加入属性 

<Table    
   bordered
   pagination={ paginationProps }
   //双击表格行触发
   onRowDoubleClick={this.dbClick }
   columns={ this.columns }
   dataSource={ this.dataSource }
   style={{ marginTop: '10px' }}
   className="tablestyle"
   scroll={{ y: 280 }}
 />

3、定义  dbClick 方法

// 双击表格行(Row)执行
  dbClick = (record) => {
   
    const { dispatch } = this.props;
    dispatch(routerRedux.push({
      pathname:'/ltList/lzpDetail', // 这个路由为要跳转的页面(在router.config中定义)
      record: record,  // 传的值,这里的值为表格那一行的值
    }))
  };

4、在要跳转的页面中通过this.props的方式获取只

// 获取疑点列表表格行的数据
    let doubtData = {};
    doubtData = this.props.location.record !== undefined ? this.props.location.record : {};

 

props中的值