【问题标题】:How to pass prop for an image stored locally in react-native如何为本地存储在 react-native 中的图像传递道具
【发布时间】:2018-06-18 19:56:12
【问题描述】:

我试图在 react-native 组件的 IMAGE 标记中为“require”传递一个道具。但是,它显示错误“服务器代码错误 500”。如果我使用 URI 传递链接,它与道具一起使用。

工作:

<Image
        style={{ width: 70, height: 61 }}
        source={{ uri: imgCode }}
      />


imgCode="https://i.imgur.com/edgLzLO.png"

需要修复:

<Image
          style={{ width: 70, height: 61 }}
          source={require('./images/header_arrow.png')}
        />

imgCode="./images/batter_logo.png"

【问题讨论】:

标签: image react-native local react-props react-image


【解决方案1】:
<Image
    style={{ width: 70, height: 61 }}
    source={require({ uri: imgCode })}
  />


imgCode="https://i.imgur.com/edgLzLO.png"

试试这个可能有用

【讨论】:

    猜你喜欢
    • 2018-03-24
    • 1970-01-01
    • 2018-05-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2023-03-28
    • 2018-05-22
    • 1970-01-01
    相关资源
    最近更新 更多