本机缩略图不接受图像源

问题描述 投票:0回答:2

我使用native-base来显示缩略图源,我收到错误

Error: The <Image> component cannot contain children. If you want to render content on the top of the image, consider using the <ImageBackground> component or absolute positioning.

这是我尝试过的错误:

import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';

import { Card, CardItem, Thumbnail, Body, Left, Right, Button, Icon } from 'native-base';

class CardComponent extends Component {
    render() {
        return (
            <Card>
                <CardItem>
                    <Left>
                        <Thumbnail source={require('../assets/me.png')}>
                            <Body>
                                <Text>Username</Text>
                                <Text note>August 29, 2018</Text>
                            </Body>
                        </Thumbnail>
                    </Left>
                </CardItem>
            </Card>
        );
    }
}
react-native native-base
2个回答
1
投票

试试这个,这对你有用。

<Card>
   <CardItem>
       <Left>
          <Thumbnail source={require('../assets/me.png')}/>
             <Body>
                 <Text>Username</Text>
                 <Text note>August 29, 2018</Text>
             </Body>
      </Left>
   </CardItem>
</Card>

0
投票

使用<ImageBackground>标记在图像上附加文本。

请参阅此ImageBackground

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