当前位置: 首页 > 工具软件 > react-query > 使用案例 >

React 使用query在路由中传递多个参数

长孙瑞
2023-12-01

参数传递方

import React from 'react';
import { history } from 'umi';
const Sending: React.FC = () => {
		// 跳转页面
    handleClick: (record: any) => {
      history.push({
        pathname: '/页面路径/Detail/',
        query: {
          stockType: record.stockType,
          pid: record.pId,
          id: record.id,
        },
      });
    },
};
export default Pending;

参数获取方

import React from 'react';
import { useLocation } from 'umi';
const Receive: React.FC = () => {
  const { query = {} }: any = useLocation();
  // 获取参数 
  const { stockType, pid, id } = query;
};
export default Receive;
 类似资料: