test:function () {
let url = 'http://image.****.com/cs.docx'
let fileName ='文件名称';
wx.showLoading({
title: '正在打开文件'
})
const manage = wx.getFileSystemManager();
wx.downloadFile({
url: url,
success (res) {
var savePath = wx.env.USER_DATA_PATH + "/" + fileName
if (res.statusCode == 200) {
manage.saveFile({
tempFilePath: res.tempFilePath,
filePath: savePath+'.docx',
success:function(res){
wx.openDocument({
filePath: res.savedFilePath,
showMenu:true,
success: function (res) {
wx.hideLoading()
}
})
}
})
}
}
})
}
转载于 https://blog.csdn.net/weixin_45740068/article/details/108596852