From e1b30a5075a2a2f9e2c538350950e6e09b6decd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E5=90=8E?= <244387066@qq.com> Date: Sat, 17 Apr 2021 22:30:53 +0800 Subject: [PATCH] fix: update Axios.ts (#492) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 应该使用传递进来的 请求头 2. 针对有数组类型的参数,应该用brackets 或者 repeat 。 最好将arrayFormat参数改成可以让使用者通过入参来改的。 参考: https://blog.csdn.net/pifutan/article/details/86320705 --- src/utils/http/axios/Axios.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts index bf887faf..ed650e71 100644 --- a/src/utils/http/axios/Axios.ts +++ b/src/utils/http/axios/Axios.ts @@ -155,7 +155,7 @@ export class VAxios { // support form-data supportFormData(config: AxiosRequestConfig) { - const headers = this.options?.headers; + const headers = config.headers; const contentType = headers?.['Content-Type'] || headers?.['content-type']; if ( @@ -168,7 +168,7 @@ export class VAxios { return { ...config, - data: qs.stringify(config.data), + data: qs.stringify(config.data, { arrayFormat: 'brackets' }), }; }