获取用户朋友的个人资料图片React-native

问题描述:

我试图检索所有用户的朋友个人资料图片以在列表视图中呈现它们。获取用户朋友的个人资料图片React-native

我得到所有用户的朋友是在这个图形请求的应用:

`const infoRequest = new GraphRequest(
     '/me', 
     { 
      parameters: { 
       fields: { 
         string: 'email, name, first_name, middle_name, 
       last_name, picture.type(large), cover, birthday, location, friends' 
        } 
       } 
      }, 
      this._responseInfoCallback 
     );` 

于是,我试图使他的朋友的个人资料图片使用此功能

`renderFriends() { 
     if(this.state.user != null) { 
     return this.state.user.friends.data.map(friend => 
      <View> 
      <Image 
       source={{uri:'https://graph.facebook.com/{friend.id}/picture? 
         type=large'}} 
       style={styles.profilePicture} 
      /> 
      <Text key={friend.id} >{friend.name}</Text> 
      </View> 
     ) 
     } 
    }` 

所有名称渲染正确,但图像不呈现。

您可以查看下面的图像的风格:

`profilePicture: { 
    height: 120, 
    width: 120, 
    borderRadius: 60, 
    marginTop: height/15, 
    },` 

变化

{{ uri: 'https://graph.facebook.com/{friend.id}/picture?type=large' }} 

通过

{{ uri: 'https://graph.facebook.com/' + friend.id + '/picture?type=large' }} 

{friend.id}没有得到通过朋友的ID所取代,这是解释为文字字符串{friend.id},它给你错误的网址。