js 参数序列化

复制代码
export const getParamsToString = (obj) => {
  let str = '';
  for (const key in obj) {
    str += `${key}=${obj[key]}&`;
  }
  return str.substr(0, str.length - 1);
};

export const getParamsToString1 = (obj) => {
  let str = '';
  for (const key in obj) {
    str += `${key}=${encodeURIComponent(obj[key])}&`;
  }
  return str.substr(0, str.length - 1);
};
复制代码

 

posted @   拈花醉  阅读(1275)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示