【发布时间】:2017-08-07 09:35:17
【问题描述】:
我正在构建一个简单的社交媒体应用程序。用户可以添加状态、位置、来自 youtube 的视频和照片。但是我在使用 react native image picker 上传多张图片时遇到了问题。我已阅读文档,但我不知道如何解决问题
这是我的功能代码
onPhotoPress() {
const options = {
quality: 1.0,
maxWidth: 50,
maxHeight: 50,
storageOptions: {
skipBackup: true,
},
};
ImagePicker.launchImageLibrary(options, openPicker(), (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled photo picker');
}
else if (response.error) {
console.log('ImagePicker Error: ', response.error);
}
else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
}
else {
const source = { uri: `data:image/jpeg;base64,${response.data}` };
this.setState({
avatarSource: source,
name: response.fileName,
data: response.data,
type: response.type,
path: response.uri,
});
}
});
}
这是我查看图片的代码
{this.state.avatarSource !== null ?
<Image
source={this.state.avatarSource}
style={{
flex: 1,
resizeMode: 'contain',
marginVertical: 12,
}}
/> : <View /> }
所以你能帮我获取多张图片或给我建议我应该使用另一个库来解决我的问题
【问题讨论】:
标签: react-native