小程序api里有一个叫:wx.openDocument 功能是在新的页面打开文档

通过文档可以看到filePath是通过downloadFile下载到临时路径
实例代码:
wx.downloadFile({
url: 'www.file.com/file.ppt',//可以是后台传过来的路径
success: function(res) {
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function(res) {
//成功
}
})
}
})
注意:小程序本地文件储存的大小限制为10M

网友评论