UNPKG

856 BTypeScriptView Raw
1/**
2 * @description 上传的核心方法
3 * @author wangfupeng
4 */
5import { DicType } from '../../config/index';
6declare type PostOptionType<T> = {
7 timeout?: number;
8 formData?: FormData;
9 headers?: DicType;
10 withCredentials?: boolean;
11 onTimeout?: (xhr: XMLHttpRequest) => void;
12 onProgress?: (percent: number, event: ProgressEvent) => void;
13 beforeSend?: (xhr: XMLHttpRequest) => {
14 prevent: boolean;
15 msg: string;
16 } | void;
17 onError?: (xhr: XMLHttpRequest) => void;
18 onFail?: (xhr: XMLHttpRequest, msg: string) => void;
19 onSuccess: (xhr: XMLHttpRequest, result: T) => void;
20};
21/**
22 * 发送 post 请求(用于文件上传)
23 * @param url url
24 * @param option 配置项
25 */
26declare function post<T extends Object>(url: string, option: PostOptionType<T>): XMLHttpRequest | string;
27export default post;