0
我建立了一個Appcication像簡單的社交媒體。用戶可以添加狀態,位置,來自YouTube的視頻和照片。但我有問題上傳多個圖像使用反應本機圖像選擇器。我讀過的文件,但我沒有任何想法解決這個問題如何添加多個圖像使用反應本機圖像選擇器
這裏是我的功能代碼
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 /> }
所以你能幫助我,獲得多個圖像或給我建議另一個庫,我應該用來解決我的問題