问答

react-native中SectionList设置getItemLayout导致上滑没有加载?

作者:admin 2021-08-11 我要评论

getItemLayout={(data, index) = { console.log('_getLen getItemLayout', {index}); const len = this._getLen(index); return { length: len.length + 960, of...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)
getItemLayout={(data, index) => {
  console.log('_getLen getItemLayout', {index});
  const len = this._getLen(index);
  return {
    length: len.length + 960,
    offset: len.offset,
    index,
  };
}}

1.这么写我发现上滑没有加载余下的部分,不知道为什么?
2.用如下方法调用 scrollToLocation,传入参数 sectionIndex1 , 而上面 console.log('_getLen getItemLayout', {index}); 却输出 _getLen getItemLayout', { index: 5 }
为什么传入 1 而得到 5 呢?

this.SectionList.scrollToLocation({
 animated: false,
 itemIndex: 0,
 sectionIndex: 1,
 viewOffset: 0,
});

有一个类似的问题:
https://segmentfault.com/q/10...

这是官方文档: https://reactnative.cn/docs/v...

我的每一行长度是可以计算出来的,通过 this._getLen,

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • react-native中SectionList设置getItem

    react-native中SectionList设置getItem

  • 这IDEA在忙什么?

    这IDEA在忙什么?

  • LinkedBlockingQueue如何保证多线程环

    LinkedBlockingQueue如何保证多线程环

  • ajax获取导航

    ajax获取导航

腾讯云代理商
海外云服务器