小程序请求参数为null或undefined传到后端为对应的字符

2021-07-28  本文已影响0人  斡旋_ASL
function requestParamHandler(params: any): any  {
  if (typeof params == "object") {
    for (let key of Object.keys(params)) {
      if (params[key] == null) {
        delete params[key];
      }
      if (params[key] instanceof Array) {
        const arr: any[] = [];
        const list: any[] = params[key];
        for (let listElement of list) {
          const abj = requestParamHandler(listElement);
          abj && arr.push(abj);
        }
        params[key] = arr;
      }
    }
  }
  return params;
}
上一篇 下一篇

猜你喜欢

热点阅读