import { history } from 'umi';// 假设你想添加一个名为"newParam"的query参数,值为"newValue"
function addQueryParamToUrl(paramName, paramValue) {const { search, pathname } = history.location;const newSearchParams = new URLSearchParams(search);newSearchParams.set(paramName, paramValue);const newSearch = `?${newSearchParams.toString()}`;history.push(`${pathname}${newSearch}`);
}// 使用函数
addQueryParamToUrl('newParam', 'newValue');