javascript 构建url

使用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
};
相关推荐
六件套是我1 小时前
无法访问org.springframeword.beans.factory.annotation.Value
java·开发语言·spring boot
S-码农1 小时前
Linux ——条件变量
linux·开发语言
清水白石0081 小时前
《Python 编程全景解析:从核心精要到 Hypothesis 属性基测试的边界探索》
开发语言·python
IT枫斗者1 小时前
IntelliJ IDEA 2025.3史诗级更新:统一发行版+Spring Boot 4支持,这更新太香了!
java·开发语言·前端·javascript·spring boot·后端·intellij-idea
N***p3651 小时前
Spring Boot项目接收前端参数的11种方式
前端·spring boot·后端
NGC_66112 小时前
二分查找算法
java·javascript·算法
勇往直前plus2 小时前
深入理解 Python 内存模型:模块、类、对象的存储与运行机制
开发语言·python
派大星-?2 小时前
自动化测试五模块一框架(下)
开发语言·python
享誉霸王2 小时前
15、告别混乱!Vue3复杂项目的规范搭建与基础库封装实战
前端·javascript·vue.js·前端框架·json·firefox·html5