但是不管能不能成功打开控制台查看wx.openDocument永远都是返回成功的回调
{errMsg: "openDocument:ok"}
相关代码长这样
wx.openDocument({
filePath: res.tempFilePath,
fileType: type,
success: function (res) {
console.log('打开文件成功')
console.log(res, type, useType, '2131231')
},
fail: function (res) {
console.log(res, type, 'openDocument')
if (platform === 'android') {
wx.showModal({
title: '打开文档失败',
content: '请下载QQ浏览器后,再次打开文件',
confirmText: '确定',
showCancel: false,
})
} else {
wx.showModal({
title: '打开文档失败',
content: '请复制文件下载地址到浏览器中打开',
confirmText: '复制',
showCancel: false,
success: function (e) {
if (e.confirm) {
copyfileUrl(copyUrl);
}
}
})
}
},
})
我也是如此,请问解决了吗
wx.downloadFile({ url: 'https://xxxxx/uploadFile/file/userGuide.pdf', success: function (res) { var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用 wx.openDocument({ filePath: Path, success: function (res) { console.log('打开成功'); } }) }, fail: function (res) { console.log(res); } })