基于umi路由跳转携带数据--待完善

600 阅读1分钟

1.路由跳转 1.1_在table列表中点击数据进行跳转页面 使用umi中自带的Link的to方法进行路由跳转

`

 import { Link } from 'umi';
 
 {title: '操作',
 dataIndex: 'action',
 render: (text, record) => {
  return (
   <span className={styles.action}>
    <Link
      style={{ marginRight: '10px' }}
      to={`/rule/detail?type=edit&id=${record.id}`}
     >
     编辑
     </Link>
      <a onClick={() => deleteFun(record)}>删除</a>
      </span>
    );
  }}

`

1.2_直接使用umi自带的history进行路由跳转

`

import { history } from 'umi';

 const creactButton = () => {
    history.push({
      pathname: '/rule/detail',
      query: {
      id: 2
    });
    console.log('创建');
  };

`

2.返回按钮

`

  const goBack = () => {
    history.goBack();
  };

`