小程序
小游戏
企业微信
微信支付
扫描小程序码分享
报错信息: downloadFile:fail Error:Parse Error
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
我的代码一样的没有另存为按钮,最后解决了吗?
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
wx.showLoading({ title: '下载中', mask:true })
//先下载,再打开
wx.downloadFile({
url: url,
header: "application/json",
success: function (res) {
wx.showLoading({ title: '打开中', mask:true })
let filePath = res.tempFilePath
console.log("文件临时路径",res.tempFilePath)
let type = res.tempFilePath.slice(res.tempFilePath.lastIndexOf(".")+1)
console.log("文件type",type)
that.fileCacheMap.set(url, filePath);
//打开文档
wx.openDocument({
filePath: filePath,
fileType: type,
success: function (res) { },
complete: function (res) {
wx.hideLoading()
}
})
},
fail: function(res){
console.log("fail-res",res)
//打印如下: errMsg: "downloadFile:fail Error: Parse Error"
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
建议最好代码片段写一个吧。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
我的代码一样的没有另存为按钮,最后解决了吗?
wx.showLoading({ title: '下载中', mask:true })
//先下载,再打开
wx.downloadFile({
url: url,
header: "application/json",
success: function (res) {
wx.showLoading({ title: '打开中', mask:true })
let filePath = res.tempFilePath
console.log("文件临时路径",res.tempFilePath)
let type = res.tempFilePath.slice(res.tempFilePath.lastIndexOf(".")+1)
console.log("文件type",type)
that.fileCacheMap.set(url, filePath);
//打开文档
wx.openDocument({
filePath: filePath,
fileType: type,
success: function (res) { },
complete: function (res) {
wx.hideLoading()
}
})
},
fail: function(res){
console.log("fail-res",res)
//打印如下: errMsg: "downloadFile:fail Error: Parse Error"
},
complete: function (res) {
wx.hideLoading()
}
})
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
建议最好代码片段写一个吧。
//先下载,再打开
wx.downloadFile({
url: url,
header: "application/json",
success: function (res) {
wx.showLoading({ title: '打开中', mask:true })
let filePath = res.tempFilePath
console.log("文件临时路径",res.tempFilePath)
let type = res.tempFilePath.slice(res.tempFilePath.lastIndexOf(".")+1)
console.log("文件type",type)
that.fileCacheMap.set(url, filePath);
//打开文档
wx.openDocument({
filePath: filePath,
fileType: type,
success: function (res) { },
complete: function (res) {
wx.hideLoading()
}
})
},
fail: function(res){
console.log("fail-res",res)
//打印如下: errMsg: "downloadFile:fail Error: Parse Error"
},
complete: function (res) {
wx.hideLoading()
}
})
去掉