ajax动态获取的数据有空字段,拼接html会在页面显示undefined
解决方法:
利用三目运算符
将""+item.value+"“改为
“”+(item.value==undefined?”——":item.value)+""
记得要加括号,为undefined时要改为显示的方式用引号括起来。
ajax请求获取数据为空时显示undefined
最新推荐文章于 2022-12-25 22:23:43 发布
ajax动态获取的数据有空字段,拼接html会在页面显示undefined
解决方法:
利用三目运算符
将""+item.value+"“改为
“”+(item.value==undefined?”——":item.value)+""
记得要加括号,为undefined时要改为显示的方式用引号括起来。