Commit c70cf3cace62416eea32a787b000cd9ed2055ed2
Committed by
GitHub
1 parent
4f4bec0c
fix 主动调用 axioscancelToken 的 cancel 取消请求时 无效的问题 (#2586)
cancelToken 如果被深拷贝,会导致最外层无法使用cancel方法来取消请求
Showing
1 changed file
with
5 additions
and
0 deletions
src/utils/http/axios/Axios.ts
... | ... | @@ -193,6 +193,11 @@ export class VAxios { |
193 | 193 | |
194 | 194 | request<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> { |
195 | 195 | let conf: CreateAxiosOptions = cloneDeep(config); |
196 | + // cancelToken 如果被深拷贝,会导致最外层无法使用cancel方法来取消请求 | |
197 | + if(config.cancelToken){ | |
198 | + conf.cancelToken = config.cancelToken | |
199 | + } | |
200 | + | |
196 | 201 | const transform = this.getTransform(); |
197 | 202 | |
198 | 203 | const { requestOptions } = this.options; | ... | ... |