填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

HttpParams

HTTP 请求/响应体,用来表示序列化参数,它们的 MIME 类型都是 application/x-www-form-urlencoded

An HTTP request/response body that represents serialized parameters, per the MIME type application/x-www-form-urlencoded.

查看"说明"...

      
      class HttpParams {
  constructor(options: HttpParamsOptions = {} as HttpParamsOptions)
  has(param: string): boolean
  get(param: string): string | null
  getAll(param: string): string[] | null
  keys(): string[]
  append(param: string, value: string): HttpParams
  set(param: string, value: string): HttpParams
  delete(param: string, value?: string): HttpParams
  toString(): string
}
    

说明

这个类是不可变的 - 每个修改类的操作都会返回一个新实例。

This class is immutable; all mutation operations return a new instance.

构造函数

constructor(options: HttpParamsOptions = {} as HttpParamsOptions)
      
      constructor(options: HttpParamsOptions = {} as HttpParamsOptions)
    
参数
options HttpParamsOptions

可选. 默认值是 {} as HttpParamsOptions.

方法

Reports whether the body includes one or more values for a given parameter.

has(param: string): boolean
      
      has(param: string): boolean
    
参数
param string

The parameter name.

返回值

boolean: True if the parameter has one or more values, false if it has no value or is not present.

Retrieves the first value for a parameter.

get(param: string): string | null
      
      get(param: string): string | null
    
参数
param string

The parameter name.

返回值

获取给定参数名对应的第一个值,如果没有则返回 null

string | null: The first value of the given parameter, or null if the parameter is not present.

Retrieves all values for a parameter.

getAll(param: string): string[] | null
      
      getAll(param: string): string[] | null
    
参数
param string

The parameter name.

返回值

获取给定参数名对应的所有值,如果没有则返回 null

string[] | null: All values in a string array, or null if the parameter not present.

Retrieves all the parameters for this body.

keys(): string[]
      
      keys(): string[]
    
参数

没有参数。

返回值

string[]: The parameter names in a string array.

Appends a new value to existing values for a parameter.

append(param: string, value: string): HttpParams
      
      append(param: string, value: string): HttpParams
    
参数
param string

The parameter name.

value string

The new value to add.

返回值

构造一个新的 body,添加一个具有给定参数名的值。

HttpParams: A new body with the appended value.

Replaces the value for a parameter.

set(param: string, value: string): HttpParams
      
      set(param: string, value: string): HttpParams
    
参数
param string

The parameter name.

value string

The new value.

返回值

构造一个新的 body,具有一个给定参数名的新值。

HttpParams: A new body with the new value.

Removes a given value or all values from a parameter.

delete(param: string, value?: string): HttpParams
      
      delete(param: string, value?: string): HttpParams
    
参数
param string

The parameter name.

value string

可选. 默认值是 undefined.

The value to remove, if provided.

返回值

构造一个新的 body,如果指定了 value,则移除具有指定 value 和指定 param 的条目;如果没有指定 value,则移除指定 param 对应的所有值。

HttpParams: A new body with the given value removed, or with all values removed if no value is specified.

把该 body 序列化为一个编码过的字符串,其中的 key-value 对(用 = 分隔)会以 & 分隔。

Serializes the body to an encoded string, where key-value pairs (separated by =) are separated by &s.

toString(): string
      
      toString(): string
    
参数

没有参数。

返回值

string