The data returned by the backend is like this, displayed on the page is all null, so you need to determine whether the field returned is null and then convert an empty string. function nullToStr(data) { for (var x in data) { if (data[x] === null) {// If it is null, convert the direct content to `` data[x] = ''; } else { if (Array.isArray(data[x])) {// It is an array to traverse the array and continue processing recursively data[x] = data[x].map(z => { return nullToStr(z); }); } if(typeof(data[x]) ==='object'){ // is json recursively continue processing data[x] = nullToStr(data[x]) } } } return data; }
js converts null in json data to ``empty string
Guess you like
Origin blog.csdn.net/weixin_42217154/article/details/108048292
Recommended
Ranking