UNPKG

@gdjiami/jslib

Version:

Jiami FrontEnd helpers and Services

62 lines (61 loc) 1.37 kB
/** * 解析查询字符串 * * @example * ```js * getSearch('?id=1&name=a') * ``` * * @param search 查询字符串 * * @returns 格式化后对象 */ export declare function getSearch(search: string): any; /** * 格式化对象为查询字符串, 不包含‘?’前缀 * * @example * ```js * searchStringify({id: 1, name: 'a'}) * ``` * * @param obj 格式化对象 * * @returns 格式化后字符串 */ export declare function searchStringify(obj: object): string; /** * 追加查询字符串到url上 * * @example * ```js * appendQuery('xxx.html?id=1', { name: 'a' }) * ``` * * @returns 追加后的 url */ export declare function appendQuery(url: string, obj: object): string; /** * JSONP 请求 * @param url 请求地址 * @param params 请求参数 * @param options 设置,可配置回调函数及超时时间 */ export declare function jsonp<T>(url: string, params: object, options?: { callback?: string; timeout?: number; }): Promise<T>; /** * 获取地址参数 * @param key 参数 key 值 * * @example * * ```js * window.location.href = 'http://xxx.html?id=007&name=test' * getUrlParam(id) // => '007' * getUrlParam(name) // => 'test' * getUrlParam(age) // => null * ``` */ export declare function getUrlParam(key: string): string | null;