反应本机 SectionList 水平模式 [英] React native SectionList horizontal mode

查看:37
本文介绍了反应本机 SectionList 水平模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题.我一直在尝试使用 SectionList 来呈现列表部分,但问题是我想在水平模式下使用列表,但我不知道该怎么做.

I've got a question. I've been trying to use SectionList for render a list section but the problem is I want to use list in horizontal mode and I don't know how to do that.

请帮助我坚持了 2 个小时.

Please help I've stuck on this for 2 hours.

这是我的代码:

<SectionList
   renderItem={({item}) => <Image source={require('../assets/images/img1.jpg')} />}
   renderSectionHeader={({section}) => <Text>{section.title}</Text>}
   sections={dataSource}
/>

推荐答案

在 ReactNative 文档中,没有用于制作水平 SectionList 的道具(从 0.48 开始),但其父 VirtualizedList 有.因此,请尝试它是否有效...

In ReactNative docs, there is no prop for making horizontal SectionList(as of 0.48), but its parent VirtualizedList has. Hence just try if it works ...

<SectionList
   horizontal={true}
/>

如果它不起作用,那么您可能应该尝试使用具有水平支撑的 Flatlist 并等待它为 SectionList

If it does not work then probably u should try using Flatlist which has a horizontal prop and wait until it's implemented for SectionList

这篇关于反应本机 SectionList 水平模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆