Skip to content

spliceUrlParam

拼接参数到 URL。

用法

js
import { spliceUrlParam } from 'js-cool'

签名

typescript
function spliceUrlParam(url: string, params: Record<string, any>): string

参数

参数类型描述
urlstring基础 URL
paramsRecord<string, any>参数对象

返回值

string - 带参数的 URL。

示例

js
spliceUrlParam('https://example.com', { name: 'John', age: 30 })
// 'https://example.com?name=John&age=30'

spliceUrlParam('https://example.com?foo=bar', { name: 'John' })
// 'https://example.com?foo=bar&name=John'

基于 MIT 许可发布