我目前正在尝试在 native react 中除了图像之外编写上部和底部文本类似于:
[Photo 1] Song Name
[Photo 1] Song Title
但是我得到了这样的东西:
[Photo 1] Song Name Song Title
歌曲的标题和名称应位于图像旁边,如标题和副标题。我尝试了很多方法,包括制作 child 文本组件,但没有成功。下面是我的代码的重新编写,供您引用:
import React, { Component } from 'react';
import { View, Image, Text } from 'react-native';
export default class DisplayAnImage extends Component {
render() {
return (
<Text>
<Image
style={{width: 50, height: 50}}
source={require('@expo/snack-static/react-native-logo.png')}
/>
<Text> Song Name </Text>
<Text> Song Title </Text>
</Text>
);
}
}
最佳答案
<View style={{ flexDirection: 'row' }}>
<Image style={{ width: 50, height: 50}} source={require('@expo/snack-static/react-native-logo.png')}
<View style={{justifyContent: 'center'}}>
<Text>this is heading</Text>
<Text>this is subheading</Text>
</View>
</View>
试试这个造型
关于javascript - React Native 中除了图像之外的上下文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58978985/