提交 5485a545 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

update: 网络请求示例 增加请求完毕task置空

上级 030fb758
......@@ -55,11 +55,13 @@
success: (res) => {
console.log('downloadFile success, res is', res.tempFilePath)
self.imageSrc = res.tempFilePath;
uni.hideLoading();
},
fail: (err) => {
console.log('downloadFile fail, err is:', err)
uni.hideLoading();
},
complete: (res) => {
uni.hideLoading();
this.task = null;
}
});
this.task?.onProgressUpdate((update) => {
......
......@@ -218,7 +218,8 @@
});
},
complete: () => {
uni.hideLoading()
uni.hideLoading()
this.task = null
},
});
},
......
......@@ -61,7 +61,6 @@
},
success: (res) => {
console.log('uploadImage success, res is:', res)
uni.hideLoading();
uni.showToast({
title: '上传成功',
icon: 'success',
......@@ -71,12 +70,15 @@
},
fail: (err) => {
console.log('uploadImage fail', err);
uni.hideLoading();
uni.showModal({
content: err.errMsg,
showCancel: false
});
},
},
complete: (res) => {
uni.hideLoading();
this.task = null
}
});
},
fail: (err) => {
......@@ -87,7 +89,7 @@
//自动化测试例专用
jest_uploadFile() {
const imageSrc = "/static/uni.png";
this.task = uni.uploadFile({
uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址
filePath: imageSrc,
name: 'file',
......@@ -160,7 +162,7 @@
},
jest_cookie_upload(needCookie : boolean) {
const imageSrc = "/static/uni.png";
this.task = uni.uploadFile({
uni.uploadFile({
url: 'https://request.dcloud.net.cn/api/http/header/upload',
filePath: imageSrc,
name: 'file',
......@@ -180,7 +182,7 @@
},
jest_files_upload() {
const imageSrc = "/static/uni.png";
this.task = uni.uploadFile({
uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload',
files: [
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册