Skip to content

Commit

Permalink
fix(h5): api upload abort fix #7448
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode authored and Chen-jj committed Sep 24, 2020
1 parent c20b667 commit d36af2f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/taro-h5/src/api/fileTransfer/uploadFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const createUploadTask = ({ url, filePath, formData, name, header, success, erro

xhr.onload = () => {
const status = xhr.status
clearTimeout(timeout)
success({
errMsg: `${apiName}:ok`,
statusCode: status,
Expand All @@ -57,6 +58,7 @@ const createUploadTask = ({ url, filePath, formData, name, header, success, erro
}

xhr.onerror = e => {
clearTimeout(timeout)
error({
errMsg: `${apiName}:fail ${e.message}`
})
Expand Down Expand Up @@ -92,6 +94,7 @@ const createUploadTask = ({ url, filePath, formData, name, header, success, erro
* 中断任务
*/
const abort = () => {
clearTimeout(timeout)
xhr.abort()
}

Expand Down

0 comments on commit d36af2f

Please sign in to comment.