ListItem头像不会呈现

问题描述 投票:1回答:1

我有一系列ListItems,我生成如下:

        <ScrollView>
            {
                this.state.results.map((item, i) => (
                    <ListItem key={i}
                              leftAvatar={{ source: {uri: item.image} }}
                              subtitle={
                                  <Text>{ this.createInfo(item) }</Text>
                              }
                              title={ item.key }
                              onPress={() => navigate('Route', { key: item.key, location: this.state.location })}
                    />
                ))
            }
        </ScrollView>

副标题和标题渲染得很好,但出于某种原因,无论我做什么,我都无法让头像道具出现。我尝试过使用avatar和leftAvatar prop,都没有工作。我也尝试过硬编码源头uri的头像到图像,网址,这也不起作用,所以我知道这不是由于item.image格式错误。我所看到的只是我标题左侧的一个小缩进,表明化身应该在那里。

javascript react-native listitem
1个回答
0
投票

在阅读了这个讨论之后,这对我有用:[https://github.com/react-native-training/react-native-elements/issues/444

而不是使用leftAvatar尝试:

avatar={<Image source={require('../images/icon-settings.png')}/>}]

© www.soinside.com 2019 - 2024. All rights reserved.