diff --git a/README.md b/README.md index 44d56b8..8d148c2 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,9 @@ Vue.use(VueHtml5Editor, { width: 1600, height: 1600, quality: 80, + // 请求头配置 + // request header configuration + requestHeader: {}, // 响应数据处理 // handle response data,return image url uploadHandler(responseText){ diff --git a/dist/vue-html5-editor.js b/dist/vue-html5-editor.js index 703473a..0815c6f 100644 --- a/dist/vue-html5-editor.js +++ b/dist/vue-html5-editor.js @@ -1,7 +1,7 @@ /** * Vue-html5-editor 1.0.2 * https://github.com/PeakTai/vue-html5-editor - * build at Tue Mar 14 2017 18:41:09 GMT+0800 (CST) + * build at Wed Mar 15 2017 10:51:42 GMT+0800 (CST) */ (function (global, factory) { @@ -438,6 +438,14 @@ var dashboard$3 = { }; xhr.open('POST', config.server); + + if (typeof config.requestHeader === 'object') { + Object.keys(config.requestHeader).forEach(function (key) { + xhr.setRequestHeader(key, config.requestHeader[key]); + }); + } + + xhr.send(formData); } } diff --git a/src/modules/image/dashboard.js b/src/modules/image/dashboard.js index 7cf6bed..a7ec705 100644 --- a/src/modules/image/dashboard.js +++ b/src/modules/image/dashboard.js @@ -127,6 +127,14 @@ export default { } xhr.open('POST', config.server) + + if (typeof config.requestHeader === 'object') { + Object.keys(config.requestHeader).forEach((key) => { + xhr.setRequestHeader(key, config.requestHeader[key]) + }) + } + + xhr.send(formData) } }