1234567891011121314151617181920212223 |
- //清除空键值对
- //自定义判断元素类型
- function toType(obj)
- {
- return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
- }
- export const filter_param = (o) => {
- for(var key in o)
- {
- if(o[key]==null)
- delete o[key];
- if(toType(o[key])=="string")
- {
- o[key] = o[key].trim();
- if(o[key].length==0)
- {
- delete o[key];
- }
- }
- }
- return o;
- }
|