wx.openDocument
可打开文件类型有:
doc | doc 格式 |
docx | docx 格式 |
xls | xls 格式 |
xlsx | xlsx 格式 |
ppt | ppt 格式 |
pptx | pptx 格式 |
pdf 格式 |
主要代码:
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('打开文档成功')
},
fail: function (res) {
console.log('打开文档失败')
},
})
}
})