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
};
相关推荐
东东51611 分钟前
基于ssm的网上房屋中介管理系统vue
前端·javascript·vue.js
harrain1 小时前
什么!vue3.4开始,v-model不能用在prop上
前端·javascript·vue.js
阿蒙Amon6 小时前
TypeScript学习-第7章:泛型(Generic)
javascript·学习·typescript
睡美人的小仙女1276 小时前
Threejs加载环境贴图报错Bad File Format: bad initial token
开发语言·javascript·redis
fanruitian7 小时前
uniapp android开发 测试板本与发行版本
前端·javascript·uni-app
rayufo7 小时前
【工具】列出指定文件夹下所有的目录和文件
开发语言·前端·python
RANCE_atttackkk7 小时前
[Java]实现使用邮箱找回密码的功能
java·开发语言·前端·spring boot·intellij-idea·idea
摘星编程7 小时前
React Native + OpenHarmony:Timeline垂直时间轴
javascript·react native·react.js
缺点内向7 小时前
C#编程实战:如何为Word文档添加背景色或背景图片
开发语言·c#·自动化·word·.net
一起养小猫8 小时前
Flutter for OpenHarmony 实战:记账应用数据统计与可视化
开发语言·jvm·数据库·flutter·信息可视化·harmonyos