【Ant.design Pro】跳转网址界面${传参数}

一、重要代码

const urlParams = new URL(window.location.href).searchParams;
history.push(urlParams.get('redirect') || `/跳转的网页path?${paramsText}`);
//参数格式:
paramsText = project_name=${record["project_name"]} && project_name=${record["project_name"]} 

二、columns里的操作

{title:'操作',valueType: 'option', key: 'option', align:"center",width:"10%",
      render: (text, record) => [
			<a style={{ marginLeft: '2%' }} onClick={()=>{
				const urlParams = new URL(window.location.href).searchParams;
				console.log("urlParams",urlParams)
				let paramsList = Object.entries(record)
				console.log("paramsList",paramsList)
				const paramsText = paramsList.map(([k,v])=>{
				 if(v){
				   return `${k}=${v}`
				 }
				}).join("&&")
				console.log("paramsText",paramsText)
				history.push(urlParams.get('redirect') || `/yewu/applyInfo?${paramsText}`);
				}}>跳转按钮</a>
	]
}

三、接收参数

queryParams就是接受的参数
formRef将他传给Form组件里

import { parse } from 'query-string';
import {useLocation} from "@umijs/max";


  const location = useLocation();
  const queryParams = parse(window.location.search);
  React.useEffect(() => {
    if(Object.keys(queryParams).length>0){
      formRef.current?.setFieldsValue(queryParams)
  }, []);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值