Skip to content

Commit

Permalink
feat: 🎸 support httpRequest promise for upload
Browse files Browse the repository at this point in the history
✅ Closes: view-design#1100
  • Loading branch information
ZhaoQi99 committed Oct 11, 2022
1 parent b6dd882 commit 5dcfb42
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/upload/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@
webkitdirectory: {
type: Boolean,
default: false
}
},
httpRequest: {
type: Function,
default: ajax
},
},
data () {
return {
Expand Down Expand Up @@ -250,7 +254,7 @@
let formData = new FormData();
formData.append(this.name, file);
ajax({
const options = {
headers: this.headers,
withCredentials: this.withCredentials,
file: file,
Expand All @@ -266,7 +270,11 @@
onError: (err, response) => {
this.handleError(err, response, file);
}
});
};
const req = this.httpRequest(options);
if (req && req.then) {
req.then(options.onSuccess, options.onError);
}
},
handleStart (file) {
file.uid = Date.now() + this.tempIndex++;
Expand Down

0 comments on commit 5dcfb42

Please sign in to comment.