项目中遇到Cannot read property 'length' of null
分类:
文章
•
2023-10-16 13:01:35
错误页面:
本人遇到的这个错误的原因主要是后台返回给页面的数据错误,没有数据时我返回给前台页面的是null,所以这个时候前台就会报这个Cannot read property ‘length’ of null的错误提示,当没有数据时正确的返回格式应该是一个空集合,这样才不会报错。
修改前的后台代码(报错):
接口回调结果:
修改后的后台代码(正确):
接口回调结果: