微信小程序下载并打开附件
程序员文章站
2022-06-25 12:15:45
download(e) { let t = this; $.showloading() wx.downloadFile({ url: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591007826562&di=c6d5dfb0816ec0bffb2d0bd9ee33a7ec&imgtype=0&src=http%3A%2F%2Fn...
download(e) {
let t = this;
$.showloading()
wx.downloadFile({
url: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591007826562&di=c6d5dfb0816ec0bffb2d0bd9ee33a7ec&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn01%2F173%2Fw580h393%2F20180417%2Ff585-fzcyxmv6432698.jpg',
success: function (res) {
console.log(res);
$.hideloading();
var filePath = res.tempFilePath;
console.log(filePath);
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log(res)
},
fail: function (res) {
console.log(res);
},
complete: function (res) {
console.log(res);
}
})
},
fail: function (res) {
$.toast("文件下载失败")
setTimeout(() => {
$.hideloading();
}, 2000)
},
complete: function (res) {},
})
}
本文地址:https://blog.csdn.net/WangYi0118/article/details/107457353
上一篇: 记一次使用ajax时忽略其“异步”性质而犯的低级错误
下一篇: C++静态成员函数和this指针详解