如何使用React Native中的URL显示图像数组?

时间:2019-08-19 20:31:25

标签: reactjs firebase react-native google-cloud-firestore

如何在react native中显示图像数组,图像使用URL,我尝试过此操作,但是图像未显示,控制台日志显示了图像URL,但是由于某些原因,图像未显示

{
      this.props.user.map((images) => {
        images.photos.map((image) => {
          console.log(image)
          return (
            <View>
              <Image style={{ width: 350, height: 300 }} source={{ uri: image }} />
            </View>);
        })
      })
    }

2 个答案:

答案 0 :(得分:1)

我已经创建了一个有效的代码段,请检查expo snack

// Update is called once per frame
void Update()
{
    if(hitted1){
        posi = new Vector3(42.49f, 0.5f, 163.8f); 
        player.transform.position = posi;
        hitted1 = false;
    }
}

void OnTriggerEnter(Collider other){
    if(other.name == "FPSController"){
        Debug.Log("player hit tele1");
        hitted1 = true;
    }
}

答案 1 :(得分:1)

您忘记return内部的map,也不要忘记在数组上进行迭代时添加key

{this.state.user.map(images => (
  images.photos.map(image => (
    <View key={image}>
      <Image style={{ width: 350, height: 300 }} source={{ uri: image }} />
    </View>
  ))
))}