Home Reference Source
import QsMan from 'qsman/src/qsman.js'
public class | source

QsMan

解析和维护 URL 上的参数, 接口设计参考 URLSearchParams

See:

Constructor Summary

Public Constructor
public

Member Summary

Private Members
private
private

_url: *

Method Summary

Public Methods
public

append(queryString: string | object): object

追加 URL 参数

public

delete(name: string): object

删除某个参数

public

get(name: string): string | undefined

获取找到的第一个参数值

public

获取参数的所有值

public

获取参数对象

public

has(name: string): boolean

是否有某个参数

public

获取所有参数的名称

public

replace(queryString: string | object): object

替换 URL 参数

public

set(name: string, value: string | Array<string>): object

设置参数值

public

对参数进行升序排序

public

toString(includeUndefinedValue: boolean): string

拼装 URL

Public Constructors

public constructor(url: string) source

Params:

NameTypeAttributeDescription
url string

Private Members

private _queryStringKvs: * source

private _url: * source

Public Methods

public append(queryString: string | object): object source

追加 URL 参数

Params:

NameTypeAttributeDescription
queryString string | object

Return:

object

this

public delete(name: string): object source

删除某个参数

Params:

NameTypeAttributeDescription
name string

Return:

object

this

public get(name: string): string | undefined source

获取找到的第一个参数值

Params:

NameTypeAttributeDescription
name string

要获取的参数名

Return:

string | undefined

public getAll(name: string): Array<string> source

获取参数的所有值

Params:

NameTypeAttributeDescription
name string

要获取的参数名

Return:

Array<string>

public getObject(): object source

获取参数对象

Return:

object

返回包含了所有参数的对象, 例如: {key1: 'value1', key2: 'value2', key3: ['value3', 'value4']}

public has(name: string): boolean source

是否有某个参数

Params:

NameTypeAttributeDescription
name string

Return:

boolean

public keys(): Array<string> source

获取所有参数的名称

Return:

Array<string>

public replace(queryString: string | object): object source

替换 URL 参数

Params:

NameTypeAttributeDescription
queryString string | object

Return:

object

this

public set(name: string, value: string | Array<string>): object source

设置参数值

Params:

NameTypeAttributeDescription
name string
value string | Array<string>

Return:

object

this

public sort(): object source

对参数进行升序排序

Return:

object

this

public toString(includeUndefinedValue: boolean): string source

拼装 URL

Params:

NameTypeAttributeDescription
includeUndefinedValue boolean

是否包含 undefined 值的参数, 默认为 true

Return:

string