Skip to content

url

getUrlParams 获取 Url 完整参数或指定字段参数

source

ts
import { getUrlParams } from 'fe-toolsbox'
getUrlParams('https://example.com?a=1&b=1')
// => {a:'1',b:'1'}
getUrlParams('https://example.com?a=1&b=1', 'a')
// => '1'
getUrlParams('https://example.com?a=1&b=1&a=2')
// => {a:['1','2'],b:'1'}
getUrlParams('https://example.com?a=1&b=1&a=2', 'a')
// => ['1','2']
{ "a": "1", "b": "1" }
1
{ "a": [ "1", "2" ], "b": "1" }
[ "1", "2" ]

stringifyQueryString 简单对象序列化

source

ts
import { stringifyQueryString } from 'fe-toolsbox'
stringifyQueryString({a:[1,2,3],b:{a:3},c:4})
a=1&a=2&a=3&b=%7B%22a%22%3A3%7D&c=4

fe-toolsbox 前端业务常用工具库