在前端解決顯示null值一例
用.net core2.1 api返回的JSON里包含null值,前端直接顯示出來了,影響閱讀,
用以下語句將null轉換為空字符串:
// Build html. html += "<tr>"; // Translate Null value to Empty string. for (var key in eBoardJson[i]) { if (eBoardJson[i][key] === null) eBoardJson[i][key] = ""; if (key == "matrial") html += "<td style='font-size:14px'>" + eBoardJson[i][key] + "</td>"; else html += "<td>" + eBoardJson[i][key] + "</td>"; } html += "</tr>";