enter image description here 我已经成功安装了 react-native-image-picker,对于一个新的 React Native 应用程序,链接它并通过 info.plist 文件授予正确的权限以访问相机、照片等...
尝试 openGallery() 时收到以下警告并且没有打开图像库: TypeError;undefined 不是函数(靠近 '...ImagePicker.showImagePicker...')
imagePickerHandler = () => {
ImagePicker.showImagePicker(options, response => {
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
Crop.openCropper({
path: response.uri,
includeBase64: true,
width: 800,
height: 340,
cropperStatusBarColor: theme.colors.gary1,
cropperActiveWidgetColor: theme.colors.primary,
cropperToolbarColor: theme.colors.black,
cropperToolbarWidgetColor: theme.colors.white,
}).then(image => {
this.setState({
image: image.data,
image_extension:
image.path.split('.')[image.path.split('.').length - 1],
});
});
}
});
};
在此处输入代码
答案 0 :(得分:0)
尝试进行命名导出
https://github.com/react-native-image-picker/react-native-image-picker/issues/1528
import {launchImageLibrary} from 'react-native-image-picker' fixed it
答案 1 :(得分:0)
错误来自Crop.openCropper
改成
Crop.openPicker({
path: response.uri,
includeBase64: true,
width: 800,
height: 340,
cropping: true,
cropperStatusBarColor: theme.colors.gary1,
cropperActiveWidgetColor: theme.colors.primary,
cropperToolbarColor: theme.colors.black,
cropperToolbarWidgetColor: theme.colors.white,
})