小程序预览文件修改默认的标题
我的最终文件名字是:‘手册’,大家看需求
http://xxx.com/a.pdf是我的原始文件名字
showpdf: function(){
//打开pdf文件 wx.showLoading({
title: ‘加载中…’, })
//关键代码1
let newPath =${wx.env.USER_DATA_PATH}/手册.pdf
wx.downloadFile({
url: ‘http://XXX.com/a.pdf’,
filePath: newPath, //指定目录是为了重命名
success: function (res) {
wx.openDocument({
filePath: newPath,
fileType: ‘pdf’,
showMenu: true,
success: function (res) {
console.log(res);
console.log(‘打开文档成功’)
wx.hideLoading()
},
fail: function (res) {
console.log(‘打开失败’)
},
})
} }) },