Flatlist React Native

编程入门 行业动态 更新时间:2024-10-28 19:25:52
本文介绍了Flatlist React Native - 无数据显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们正在使用 Flatlist 开发 React Native 应用程序.绑定来自 API 服务的数据 &它的工作正常.假设服务中没有可用数据,我们需要为此显示单独的设计.

We are developing a react native application using Flatlist. Binding data from API service & its working fine. Suppose no data available in service we need to display separate design for that.

我们为此使用了renderEmptyListComponent"

We are using "renderEmptyListComponent" for that

分享代码,请查看

<FlatList style={{ backgroundColor: 'white' }} data={this.state.dataSource} renderItem={({ item }) => (this.renderMovie(item))} keyExtractor={item => item.salesID} renderEmptyListComponent= {this.noItemDisplay} ItemSeparatorComponent={this.renderSeparator}> </FlatList>

请指导我如何做到这一点?

please guide me how can we do this?

推荐答案

可能想改用这个:

<FlatList style={{ backgroundColor: 'white' }} data={this.state.dataSource} renderItem={({ item }) => (this.renderMovie(item))} keyExtractor={item => item.salesID} ListEmptyComponent={this.noItemDisplay} ItemSeparatorComponent={this.renderSeparator}> </FlatList>

或者如果这也不起作用,请执行旧的三元 jsx-eroo

Or if that also doesn't work do the old ternary jsx-eroo

{ this.data ?<FLatList/>: null }

希望能帮到你

更多推荐

Flatlist React Native

本文发布于:2023-10-24 02:47:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522717.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Flatlist   React   Native

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!