W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
解釋:上傳任務(wù)對象
屬性名 | 說明 |
---|---|
UploadTask.abort | 中斷上傳任務(wù) |
UploadTask.onProgressUpdate | 監(jiān)聽上傳進(jìn)度變化事件 |
UploadTask.offProgressUpdate | 取消監(jiān)聽下載進(jìn)度變化 |
UploadTask.onHeadersReceived | 監(jiān)聽上傳的 HTTP Response Header 事件 |
UploadTask.offHeadersReceived | 取消監(jiān)聽上傳的 HTTP Response Header 事件 |
無
<button bindtap="createUploadTask">創(chuàng)建uploadFile實(shí)例對象</button>
Page({
createUploadTask() {
const uploadTask = swan.uploadFile({
url: 'https://xxxx', // 僅為示例,并非真實(shí)的接口地址
filePath: "https://b.bdstatic.com/searchbox/icms/searchbox/img/location_blue.png",
name: 'myfile',
header: {
'content-type': 'application/json'
},
formData: {
'user': 'swan'
},
success: res => {
swan.showToast({
title: '上傳成功',
icon: 'none'
});
console.log('uploadFile success', res);
},
fail: err => {
console.log('uploadFile fail', err);
swan.showToast({
title: '上傳失敗',
icon: 'none'
});
},
complete: () => {
console.log('uploadFile complete');
}
});
swan.showModal({
title: '創(chuàng)建' + uploadTask._reqId,
content: JSON.stringify(uploadTask)
});
}
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: