我正在使用expo和ImagePicker。我已经将文件上传到服务器(我的本地机器(,但当我试图在iPhone上显示文件时,什么都没有。我找到了路径,但组件不起作用。
我的路径是
"http://127.0.0.1:8086/storage/avatars/17/1396229C-A76B-42CD-9F15-D6F2E223D531.jpg",
和Avatar组件
<Avatar
size={120}
rounded
onPress={this.onAvatarChange}
icon={{name: 'user', type: 'font-awesome'}}
source={{
uri: this.state.avatar ? this.state.avatar : 'null',
}}
showAccessory
containerStyle={styles.avatar}
/>
不要检查localhost
或http://127.0.0.1
,而是检查计算机的IP地址并使用它来替换localhost。然后你会得到类似的东西:http:**191.178.14.11**:8086/storage/avatars/17/1396229C-A76B-42CD-9F15-D6F2E223D531.jpg
这对我有用。