我使用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>
);
}
}
试试这个,这对你有用。
<Card>
<CardItem>
<Left>
<Thumbnail source={require('../assets/me.png')}/>
<Body>
<Text>Username</Text>
<Text note>August 29, 2018</Text>
</Body>
</Left>
</CardItem>
</Card>
使用<ImageBackground>
标记在图像上附加文本。
请参阅此ImageBackground