Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "http"

Index

Functions

appendQuery

  • appendQuery(url: string, obj: object): string
  • 追加查询字符串到url上

    example
    appendQuery('xxx.html?id=1', { name: 'a' })

    Parameters

    • url: string
    • obj: object

    Returns string

    追加后的 url

getSearch

  • getSearch(search: string): any
  • 解析查询字符串

    example
    getSearch('?id=1&name=a')

    Parameters

    • search: string

      查询字符串

    Returns any

    格式化后对象

getUrlParam

  • getUrlParam(key: string): null | string
  • 获取地址参数

    example
    window.location.href = 'http://xxx.html?id=007&name=test'
    getUrlParam(id) // => '007'
    getUrlParam(name) // => 'test'
    getUrlParam(age) // => null

    Parameters

    • key: string

      参数 key 值

    Returns null | string

jsonp

  • jsonp<T>(url: string, params: object, options?: object): Promise<T>
  • JSONP 请求

    Type parameters

    • T

    Parameters

    • url: string

      请求地址

    • params: object

      请求参数

    • Default value options: object = {}

      设置,可配置回调函数及超时时间

    Returns Promise<T>

searchStringify

  • searchStringify(obj: object): string
  • 格式化对象为查询字符串, 不包含‘?’前缀

    example
    searchStringify({id: 1, name: 'a'})

    Parameters

    • obj: object

      格式化对象

    Returns string

    格式化后字符串

Generated using TypeDoc