【发布时间】:2021-06-10 07:46:30
【问题描述】:
enter image description here 我已经成功安装了 react-native-image-picker,对于一个全新的 react native 应用程序,将其链接并通过 info.plist 文件授予正确的权限以访问相机、照片等...
当尝试 openGallery() 时,我收到以下警告并且没有图像库打开: TypeError;undefined is not a function ('...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],
});
});
}
});
};
在此处输入代码
【问题讨论】:
-
错误具体告诉你错误发生在哪一行。您没有在代码块中提供行号,所以请准确告诉我们哪个函数调用失败。