1***@qq.com
1***@qq.com
  • 发布:2021-01-28 17:06
  • 更新:2021-01-28 17:06
  • 阅读:975

uni.downloadFile()下载成功后,再用uni.openDocument()打开,安卓能正常打开但是ios不能,报912

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 2.6.5

第三方开发者工具版本号: v1.0.2.2004020

基础库版本号: 2.9.2

项目创建方式: HBuilderX

示例代码:

var url = urls.BASE_PATH + '/file/' + file.wjxxbsId;
console.log(url)
var fileType = file.wjlx;
console.log(fileType);
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: encodeURI(url),
success: function (res) {
console.log(res)
var filePath = res.tempFilePath; // 小程序中文件的临时文件
uni.hideLoading();
uni.openDocument({
filePath: filePath,
fileType: String(fileType),
showMenu: true, // 允许出现分享功能
success: function (res) {
console.log(res);
console.log('打开文档成功')
},
fail: (e) => {
console.log(e);
}
})
}
})

操作步骤:

1.uni.downloadFile()
2.uni.openDocument()

预期结果:

安卓和ios都能打开

实际结果:

安卓能打开,ios不能报912

bug描述:

uni.openDocument()打开附件,安卓能正常打开但是ios不能,报912

测试是使用的附件是:xx.xlsx

猜测原因:安卓下载后的临时路劲带有后缀,但是ios没有

2021-01-28 17:06 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复