UNPKG

@tarojs/plugin-http

Version:

Taro 小程序端支持使用 web 请求 的插件

55 lines (54 loc) 2.15 kB
import { Events, TaroEvent } from '@tarojs/runtime'; export interface XMLHttpRequestEvent extends TaroEvent { target: XMLHttpRequest; currentTarget: XMLHttpRequest; loaded: number; total: number; } export declare class XMLHttpRequest extends Events { #private; static readonly UNSENT = 0; static readonly OPENED = 1; static readonly HEADERS_RECEIVED = 2; static readonly LOADING = 3; static readonly DONE = 4; static toString(): string; toString(): string; /** 当 request 被停止时触发,例如当程序调用 XMLHttpRequest.abort() 时 */ onabort: ((e: XMLHttpRequestEvent) => void) | null; /** 当 request 遭遇错误时触发 */ onerror: ((e: XMLHttpRequestEvent) => void) | null; /** 接收到响应数据时触发 */ onloadstart: ((e: XMLHttpRequestEvent) => void) | null; /** 请求成功完成时触发 */ onload: ((e: XMLHttpRequestEvent) => void) | null; /** 当请求结束时触发,无论请求成功 ( load) 还是失败 (abort 或 error)。 */ onloadend: ((e: XMLHttpRequestEvent) => void) | null; /** 在预设时间内没有接收到响应时触发 */ ontimeout: ((e: XMLHttpRequestEvent) => void) | null; /** 当 readyState 属性发生变化时,调用的事件处理器 */ onreadystatechange: ((e: XMLHttpRequestEvent) => void) | null; constructor(); addEventListener(event: string, callback: (arg: any) => void): void; removeEventListener(event: string, callback: (arg: any) => void): void; /** * 对外属性和方法 */ get timeout(): number; set timeout(timeout: number); get status(): number; get statusText(): any; get readyState(): number; get responseType(): string; set responseType(value: string); get responseText(): null; get response(): null; get withCredentials(): boolean; set withCredentials(value: boolean); abort(): void; getAllResponseHeaders(): string; getResponseHeader(name: any): string | null; open(method: any, url: any): void; setRequestHeader(header: any, value: any): void; send(data: any): void; }