wx.openDocument() 回调成功却无法打开pdf文件。
- 预期表现
每次调用可以直接打开pdf
最近的开发重要用到预览pdf 文件的需求,使用了代码如下
wx.showLoading({ title: 'pdf预览准备中', }) wx.downloadFile({ url: e.currentTarget.dataset.pdf, success(res) { console.log(res) const filePath = res.tempFilePath setTimeout(function() { wx.openDocument({ fileType:"pdf", filePath:filePath, success:function(res) { console.log(res) wx.hideLoading() }, fail:function(e) { console.log(e) } }) }, 300) } }) |
上述代码在微信开发者工具中可以顺利运行。
在手机端(安卓)可以运行,其中两次回调皆为success,但是无法打开pdf文件。
IOS端则在使用了更新的基础库(2.7.0)且开启调试之后可以正常使用。
