DownloadTask.abort
解释:中断下载任务
方法参数
无
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
Page({ data: { }, downloadFile() { const downloadTask = swan.downloadFile({ url: 'https://smartprogram.baidu.com/docs/img/file-simple.pdf', header: { 'content-type': 'application/json' }, success: res =>{ console.log(res.tempFilePath); swan.showToast({ title: '下载成功', icon: 'none' }); }, fail: err => { swan.showToast({ title: '下载失败', icon: 'none' }); console.log('错误码:' + err.errCode); console.log('错误信息:' + err.errMsg); } }); this.downloadTask = downloadTask; }, abortDownloadFile() { swan.showModal({ title: 'title', content: '已断掉' }); this.downloadTask.abort(); }});
