wx.downloadFile({
url: ‘https://www.xxxx.com/api/wechat/nfiles/download?fileid=1&userid=1’, //仅为示例,并非真实的资源
success: function (res) {
// this.setData({
// files: res.tempFilePath
// })
wx.openDocument({
filePath: res.tempFilePath,
success: function (res) {
console.log(‘打开文档成功’)
}
})
}
文件下载好了没反应,提示unable to find app to open this type of document
解决了,必须要加fileType: “pdf” 才可打开
wx.downloadFile({
// 示例 url,并非真实存在
url: ‘https://www.xxxx.com/api/wechat/nfiles/download?fileid=1&userid=1’,
success: function (res) {
const filePath = res.tempFilePath
//更具filePath确定文档类型
console.log(‘打开’ +filePath)
wx.openDocument({
filePath: filePath,
fileType: “pdf”,
success: function (res) {
console.log(‘打开文档成功’)
}
})
}
})