9***@qq.com
9***@qq.com
  • 发布:2023-05-05 10:04
  • 更新:2023-08-04 14:14
  • 阅读:1022

【报Bug】uni.chooseImage 在h5 选择相册上传 只能选择最近图片上传 选择相册 没反应

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.7.11

浏览器平台: 微信内置浏览器

浏览器版本: 微信8.0.35

项目创建方式: HBuilderX

示例代码:

uni.chooseImage({
count: 9 - that.imgList.length, //默认9
sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
success: function(res) {
alert(JSON.stringify(res))
console.log(res, 'res照片');
let self = {};
self.src = res.tempFilePath;
uni.showLoading({
title: '上传中',
mask: true
});
res.tempFilePaths.forEach(function(item, index, arr) {
console.log(index, 'indexindexindex');
uni.uploadFile({
url: baseUrl.api + '/file/upload', //真实的接口地址
filePath: res.tempFilePaths[index],
name: 'file',
fileType: 'image',
success: uploadFileRes => {
that.videoList = [];
let aaa = uploadFileRes.data;
aaa = JSON.parse(uploadFileRes.data);
let obj = {};
obj.fileName = aaa.data.name;
obj.fileUrl = aaa.data.url;
obj.type = '0';
that.imgList.push(obj);
uni.hideLoading();
},
fail: err => {
uni.hideLoading();
uni.showToast({
title: '上传失败',
icon: 'none'
});
console.log(err, 'errrrrr');
}
});
});
},
complete:function(err){
alert(JSON.stringify(err))
}
});

操作步骤:

点击相册没反应

预期结果:

有反应

实际结果:

没反应

bug描述:

uni.chooseImage 在h5 选择相册上传 只能选择最近图片上传 选择相册 没反应

2023-05-05 10:04 负责人:无 分享
已邀请:
hahe

hahe

限制count=1可以从相册里选择图片。

2***@qq.com

2***@qq.com

我也遇到了, 但是我是vue+vant写的H5页面, 后面发现是我开了多选, 而微信貌似不支持, 我取消掉就可以正常传了

9***@qq.com

9***@qq.com (作者)

????????????????????????????????????????????????

9***@qq.com

9***@qq.com (作者)

????????????????????????????????????????????????????

9***@qq.com

9***@qq.com (作者)

???????????????????????????????????????????????????

9***@qq.com

9***@qq.com (作者)

?????????????????????????????????????????????????????????????????????????????????????????????????

BoredApe

BoredApe - 有问题就会有答案。

微信浏览器中推荐使用微信js sdk 调用微信原生的图片选择。

BoredApe

BoredApe - 有问题就会有答案。

你可以写一个拦截器重写uni.chooseImage方法。替换成微信的wx.chooseImage

 // #ifdef H5  
        uni.addInterceptor('chooseImage', {  
            invoke(args) {  
                try {  
                    return new Promise((resolve) => {  
                        //在这里写 wx.chooseImage 方法  
                       return resolve(args);  
                    });  
                } catch (error) {  
                    console.log(error);  
                }  
            },  
        });  
 // #endif

参考文档:微信网页开发 /JS-SDK说明文档
uni.addInterceptor(STRING, OBJECT)

hahe

hahe

遇到一样的问题了,mark

要回复问题请先登录注册