首页 > 解决方案 > React 中的多张图片上传

问题描述

我正在构建一个带有本机反应的电子商务移动应用程序,我想让用户上传产品的多个图像成为可能,但我不知道要安装哪个包才能工作,我不知道甚至不知道我是否应该从头开始,这个问题更像是一个建议问题,只是为了指导我,请任何帮助都会非常棒,谢谢

标签: androidreactjsreact-native

解决方案


我使用react-native-image-cropper-picker并削减它。它允许multiple picking,base64cropping

要选择多个,您可以执行以下操作:

pickMultiple() {
        ImagePicker.openPicker({
            multiple: true,
            waitAnimationEnd: false,
            includeExif: true,
            forceJpg: true,
        }).then(images => {
            this.setState({
                imagesArray: images.map(i => {  
                    console.log('received image', i);
                    return {uri: i.path, width: i.width, height: i.height, mime: i.mime};
                })
            });
        }).catch(e => alert(e));
    }

推荐阅读