mirror of https://github.com/ElemeFE/element
Add support for httpRequest Promise (#3389)
* Add support for httpRequest Promise 添加支持httpRequest Promise * fixbug * fixbugpull/3948/head
parent
eac95e99c4
commit
81ba7084e3
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue