gpt4 book ai didi

javascript - React Native 中除了图像之外的上下文本

转载 作者:行者123 更新时间:2023-12-02 22:28:42 25 4
gpt4 key购买 nike

我目前正在尝试在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com