Commit 81ba7084 authored by 桦's avatar Committed by baiyaaaaa

Add support for httpRequest Promise (#3389)

* Add support for httpRequest Promise

添加支持httpRequest Promise

* fixbug

* fixbug
parent eac95e99
......@@ -233,7 +233,7 @@ export default {
'on-error': this.handleError,
'on-preview': this.onPreview,
'on-remove': this.handleRemove,
httpRequest: this.httpRequest
'http-request': this.httpRequest
},
ref: 'upload-inner'
};
......
......@@ -38,7 +38,10 @@ export default {
fileList: Array,
autoUpload: Boolean,
listType: String,
httpRequest: Function
httpRequest: {
type: Function,
default: ajax
}
},
data() {
......@@ -92,8 +95,7 @@ export default {
}
},
post(rawFile) {
const request = this.httpRequest || ajax;
request({
const options = {
headers: this.headers,
withCredentials: this.withCredentials,
file: rawFile,
......@@ -109,7 +111,11 @@ export default {
onError: err => {
this.onError(err, rawFile);
}
});
};
const requestPromise = this.httpRequest(options);
if (requestPromise && requestPromise.then) {
requestPromise.then(options.onSuccess, options.onError);
}
},
handleClick() {
this.$refs.input.click();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment