FlatList 与 ScrollView [英] FlatList Vs ScrollView

查看:42
本文介绍了FlatList 与 ScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

React Native 中 FlatList 和 ScrollView 的结构有何不同?

What is structure different between FlatList and ScrollView in react native?

在应用中看起来它们对于滚动视图来说是相等的,但是ScrollView比FlatList更简单,所以代码中什么时候必须使用FlatList?

It seems to they equal to each other for scrolling view in the application, but ScrollView is very simple rather than FlatList, so when we must use FlatList in code?

推荐答案

FlatListScrollView

ScrollView 将在组件加载后立即加载项目(其中的数据用于滚动).因此,所有数据都将装入RAM,并且您不能在其中使用成百上千的项目(因为性能低下).

ScrollView will load items (data in it for scrolling) immediately after component loading. So all data will mount into RAM and you can't use hundred or thousand items in it (because of low performance).

但是 FlatList 有一个更好的解决方案,它会挂载 10 个项目(默认情况下)到屏幕,如果用户滚动视图,其他项目将挂载.这是 FlatList 而不是 ScrollView 的一大收获.

But FlatList has a better solution for this issue, it will mount 10 items (by default) to screen, if user scroll view so other items will mount. It's a big gain of FlatList instead of ScrollView.

您可以在小项目(如 100 个项目)中使用 ScrollView,甚至在 10000 个项目中使用 FlatList.

you can use ScrollView in small items (like 100 items) and FlatList fro even 10000 items.

这篇关于FlatList 与 ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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