在使用GridManager的时候,有时会出现以下错误:
GridManager Error: response.totals undefined,please check totalsKey
解决方法
这个错误是由于的返回的数据中未找到totals字段,并提示检查配置项totalsKey。
如果totalsKey与接口返回字段不匹配,那么组件通过totalsKey获取到的将是undefined。
比如接口返回格式如下:
{
list: [
{name:'baukh', age: 11},
{name:'baukh2', age: 22}
],
sum: 2
}
由于totalsKey默认值为totals,当接口返回的总条数字段为sum时就需要在初始化时添加配置项: totalsKey: 'sum'。
详情可参考API - totalsKey
如果当前未配置totalsKey: 'sum',将会报出GridManager Error: response.totals undefined,please check totalsKey错误。
除此之外配置项responseHandler也可以处理该问题,但responseHandler一般用于处理更为复杂的情况。
本文解决GridManager中出现的response.totalsundefined错误,通常由totalsKey配置不当引起。通过正确设置totalsKey或使用responseHandler可避免此问题。
1029

被折叠的 条评论
为什么被折叠?



