wx.downloadFile({
// 示例 url,并非真实存在
url: 'http://example.com/somefile.pdf',
success: function (res) {
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('打开文档成功')
}
})
}
})
使用微信原生api,wx.downloadFile() 将文件下载到本地
再用wx.openDocument() 在新页面打开文件。