小编ari*_*y24的帖子

React Native Flatlist numColumns 没有生成多个列

我刚刚开始学习 React Native,这是我的第一个项目 - 新闻应用程序。不过,我已经使用 React Native Flatlist 成功渲染了新闻的图像和描述。

\n

但是当我使用numColumns制作两列时,列号保持不变。但显示的图像数量变成了一半(即在我的例子中从 18 到 9)。而且图像的描述位于下一条新闻的图像下方,如下所示 -

\n

\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0

\n

我的源代码如下所示 -

\n
import React, { Component } from \'react\'\nimport { View, Text, FlatList, TouchableHighlight, SectionList, TouchableOpacity , Image,StyleSheet } from \'react-native\'\nimport { ScrollView } from \'react-native-gesture-handler\';\nimport { HomeNewsJSON } from "../../../../assects/JSON/Home"\n\nclass HomeNews extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      news: ""\n    };\n  }\n\n  componentDidMount() {\n    this.getInfo();\n  }\n\n  getInfo() {\n    var data = []\n    var jsondata = HomeNewsJSON["items"]\n …
Run Code Online (Sandbox Code Playgroud)

frontend listview rendering react-native react-native-flatlist

2
推荐指数
1
解决办法
2575
查看次数