uni-app plus.share.sendWithSystem 微信分享失败问题:多文件分享仅支持照片格式
uni-app plus.share.sendWithSystem 微信分享失败问题:多文件分享仅支持照片格式
| 项目信息 | 详细信息 |
|---|---|
| 产品分类 | uniapp/App |
| PC开发环境 | Windows |
| PC开发环境版本号 | windows10 专业版 |
| HBuilderX类型 | 正式 |
| HBuilderX版本号 | 3.1.18 |
| 手机系统 | 全部 |
| 手机系统版本号 | Android 8.0 |
| 手机厂商 | 小米 |
| 手机机型 | MI5 |
| 页面类型 | nvue |
| 打包方式 | 云端 |
| 项目创建方式 | HBuilderX |
测试过的手机:
小米5 安卓8.0
示例代码:
toShareSendWithSystem(msg) {
var imageList = this.downdemo(this.webImage);
let msg1={
pictures:imageList
}
plus.share.sendWithSystem(msg1, function() {
console.log('分享成功');
}, function(e) {
console.log();
});
},
操作步骤:
- 收集后本地多张图片后,点分享按钮,成功调起功能后选私人微信,就提示错误
预期结果:
- 点分享按钮,调起功能后选私人微信,跳转到私人微信选择要发送的好友或群,点发送后多图发送出去
实际结果:
- 选私人微信后,提示:【微信:分享失败,多文件分享仅支持照片格式。选择QQ或企业微信则功能是正常的】,QQ和企业微信却是正常能用,可以发多图的
bug描述:
plus.share.sendWithSystem 私人微信分享失败,提示多文件分享仅支持照片格式,但分享到QQ、企业微信是功能正常多图分享的
更多关于uni-app plus.share.sendWithSystem 微信分享失败问题:多文件分享仅支持照片格式的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复
更多关于uni-app plus.share.sendWithSystem 微信分享失败问题:多文件分享仅支持照片格式的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这是一个微信客户端对系统分享功能的限制问题。在Android系统中,微信对通过系统分享接口接收的文件类型有严格限制。
当使用plus.share.sendWithSystem()进行多文件分享时:
-
微信的限制:微信只接受照片格式(如jpg、png等)的多文件分享,如果文件列表中包含非图片文件或图片格式不被微信识别,就会提示该错误。
-
解决方案:
- 确保
imageList中的所有文件都是标准的图片格式 - 检查文件路径和扩展名,确认都是微信支持的图片类型
- 可以在分享前对文件进行格式验证和转换
- 确保
-
代码优化建议:
toShareSendWithSystem(msg) {
// 添加文件格式过滤
var imageList = this.downdemo(this.webImage).filter(file => {
return /\.(jpg|jpeg|png|gif|bmp)$/i.test(file);
});
if(imageList.length === 0) {
console.log('没有有效的图片文件');
return;
}
let msg1 = {
pictures: imageList
};
plus.share.sendWithSystem(msg1, function() {
console.log('分享成功');
}, function(e) {
console.log('分享失败:', e);
});
}

