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
};
相关推荐
weiabc15 小时前
整数最接近等因数分解函数(汇编优化版)
开发语言·前端·javascript
小满zs15 小时前
Next.js身份验证(better-auth)
前端·seo·next.js
Highcharts.js15 小时前
专为软件团队打造的数据可视化开发工具|Highcharts图表
开发语言·信息可视化·highcharts·实战代码
yuanpan15 小时前
Python + sqlite3 本地 SQLite 数据库操作实战:完整 CRUD 入门教程
开发语言·python·opencv
rit843249915 小时前
水声通信Rake接收机-MATLAB
开发语言·matlab
sindyra15 小时前
享元模式(Flyweight Pattern)
java·开发语言·设计模式·享元模式·优缺点
codingPower15 小时前
ApplicationListener 和 SpringApplicationRunListener 深度解析对比
java·开发语言·spring boot
IMPYLH15 小时前
Linux 的 truncate 命令
linux·运维·服务器·前端·bash
ch.ju15 小时前
Java Programming Chapter 2-Recursion of function
java·开发语言
yuanpan15 小时前
Python + matplotlib 数据可视化入门教程:折线图、柱状图、饼图与 Excel 绘图
开发语言·python·opencv