You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
856 B
Plaintext
28 lines
856 B
Plaintext
11 months ago
|
/**
|
||
|
* @description 上传的核心方法
|
||
|
* @author wangfupeng
|
||
|
*/
|
||
|
import { DicType } from '../../config/index';
|
||
|
declare type PostOptionType<T> = {
|
||
|
timeout?: number;
|
||
|
formData?: FormData;
|
||
|
headers?: DicType;
|
||
|
withCredentials?: boolean;
|
||
|
onTimeout?: (xhr: XMLHttpRequest) => void;
|
||
|
onProgress?: (percent: number, event: ProgressEvent) => void;
|
||
|
beforeSend?: (xhr: XMLHttpRequest) => {
|
||
|
prevent: boolean;
|
||
|
msg: string;
|
||
|
} | void;
|
||
|
onError?: (xhr: XMLHttpRequest) => void;
|
||
|
onFail?: (xhr: XMLHttpRequest, msg: string) => void;
|
||
|
onSuccess: (xhr: XMLHttpRequest, result: T) => void;
|
||
|
};
|
||
|
/**
|
||
|
* 发送 post 请求(用于文件上传)
|
||
|
* @param url url
|
||
|
* @param option 配置项
|
||
|
*/
|
||
|
declare function post<T extends Object>(url: string, option: PostOptionType<T>): XMLHttpRequest | string;
|
||
|
export default post;
|