【问题标题】:Render image like searchScreen in Instagram在 Instagram 中像 searchScreen 一样渲染图像
【发布时间】:2018-04-23 15:18:55
【问题描述】:

我想从 db 中渲染图像,例如 Instagram searchScreen

class FeedHome extends Component {
    _renderItem = ({ item }) => <PicsContent {...item} />

    render() {

    return(
      <Root>
        <FlatList
          contentContainerStyle={{ alignSelf: 'stretch' }}
          data={data.getPosts}
          keyExtractor={item => item._id}
          renderItem={this._renderItem}
        />
     </Root>
   );
 }
}

这是 PicsContent 函数;

function PicsContent({image}) {
  return (
    <Root>
      <PicsContentContainer>
        {image}
      </PicsContentContainer>
      <PicsContentContainer>
        {image}
      </PicsContentContainer>
      <PicsContentContainer>
        {image}
      </PicsContentContainer>
   </Root>
  )
}

我把这些代码的结果都在下面的链接里。

【问题讨论】:

  • 这是图片链接:link[link]

标签: react-native


【解决方案1】:

要在 3 列中显示 FlatList 项目,如 instagram 搜索,您可以使用属性numColumns={3}

You can see this post:

【讨论】:

  • 很高兴我的回答对您有所帮助!用+1标记它,请;)
猜你喜欢
  • 2016-08-24
  • 2011-08-24
  • 1970-01-01
  • 2014-02-03
  • 1970-01-01
  • 2014-05-20
  • 2018-12-23
  • 2014-10-04
  • 1970-01-01
相关资源
最近更新 更多