使用URLSearchParams
const getLink = (params?: {}) => {
const urlParams = {
appId:'xxxx',
userId:'xxxx',
token:'xxxx',
};
const Link = 'https://xxx/xxx/xx.com';
const allParams = { ...urlParams, ...params };
const queryString = new URLSearchParams(allParams).toString();
const targetUrl = `${Link}?${queryString}`;
return targetUrl
};