Function: getURLParameters

getURLParameters(url?): Record<string, string>

获取网址参数

Parameters

Name Type Default value Description
url? string window.location.href 要解析的URL字符串,默认为当前页面URL

Returns

Record<string, string>

返回包含当前URL参数的对象

Throws

当url参数不是字符串时抛出

Example

getURLParameters('http://url.com/page?name=Adam&surname=Smith');
// => {name: 'Adam', surname: 'Smith'}

getURLParameters('https://example.com?page=1&size=10');
// => {page: '1', size: '10'}
ON THIS PAGE