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

标签 javascript html image react-native text

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

相关文章:

javascript - 为什么 Safari 会在这里提供几乎相反的结果?

javascript - 当元素由脚本动态生成并通过类选择器访问时,如何在 Jquery 中的单击事件上调用函数?

javascript - 在 Bootstrap 模式中将 javascript ID 转换为 PHP 变量

jquery - 在文本行之间添加行

JavaScript - 图像样式更改无法正常运行

php - 带有 php 循环的 CSS onmouseover 画廊

javascript - 客户端项目在端口 x 上运行,服务器 api 端点在端口 y 上运行。 AJAX如何知道webapi端点在哪里

html - CSS如何使菜单居中

javascript - 如何将一段css、html和js从一个静态模板复制到另一个?

java - 性能Image.SCALE_DEFAULT与Image.SCALE_SMOOTH