const replaceNullWithEmpty = (obj)=>{
if (typeof obj === “object” && obj !== null) {
if (Array.isArray(obj)) {
for (let i = 0; i < obj.length; i++) {
obj[i] = replaceNullWithEmpty(obj[i]);
}
} else {
for (let key in obj) {
obj[key] = replaceNullWithEmpty(obj[key]);
}
}
} else if (obj === null) {
obj = “”;
}
return obj;
}
将接口返回的数据中null 替换成““
最新推荐文章于 2024-08-27 13:51:43 发布