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 { ...@@ -233,7 +233,7 @@ export default {
'on-error': this.handleError, 'on-error': this.handleError,
'on-preview': this.onPreview, 'on-preview': this.onPreview,
'on-remove': this.handleRemove, 'on-remove': this.handleRemove,
httpRequest: this.httpRequest 'http-request': this.httpRequest
}, },
ref: 'upload-inner' ref: 'upload-inner'
}; };
......
...@@ -38,7 +38,10 @@ export default { ...@@ -38,7 +38,10 @@ export default {
fileList: Array, fileList: Array,
autoUpload: Boolean, autoUpload: Boolean,
listType: String, listType: String,
httpRequest: Function httpRequest: {
type: Function,
default: ajax
}
}, },
data() { data() {
...@@ -92,8 +95,7 @@ export default { ...@@ -92,8 +95,7 @@ export default {
} }
}, },
post(rawFile) { post(rawFile) {
const request = this.httpRequest || ajax; const options = {
request({
headers: this.headers, headers: this.headers,
withCredentials: this.withCredentials, withCredentials: this.withCredentials,
file: rawFile, file: rawFile,
...@@ -109,7 +111,11 @@ export default { ...@@ -109,7 +111,11 @@ export default {
onError: err => { onError: err => {
this.onError(err, rawFile); this.onError(err, rawFile);
} }
}); };
const requestPromise = this.httpRequest(options);
if (requestPromise && requestPromise.then) {
requestPromise.then(options.onSuccess, options.onError);
}
}, },
handleClick() { handleClick() {
this.$refs.input.click(); 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