HomeDocs
Skip to main content

DownloadTask.abort(function listener)

Introduction

Abort a download task.

Parameters

function listener

A callback function for the result of the abort operation.

Parameters

Object res

AttributeTypeDescription
successstringtrue - successful
false - failed
errCodestringError code returned when the operation fails.
errMsgstringError message returned when the operation fails.

Explanation of errMsg

Error MessageExplanation
Download Abort Fail, callbackId is empty: D009Operation failed, download task not found
Download Abort Fail, "+error+": D011Operation failed, exception information
Download Abort Fail, Exception_" + t.toString() +: D010Operation failed, error information

Sample Code

// pages/index/index.js

Page({
downloadFile() {
const downloadTask = dlt.downloadFile({
url: "xxx",
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});

downloadTask.abort((res) => {
console.log(res);
}); // Cancel the download task
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.