GB-url
Parse and set url search parameters.
English | 简体中文
Introduction
queryParam
gets the value of a parameter in window.location.search
or a string that matches the rule.
setParams
sets the value of one or more parameters in window.location.search
or a string that matches the rule, and returns [url]?p1=1&p2=2&p3=3
.
Use
npm i gb-url
import { setParams, queryParam } from "gb-url";
Get URL parameter
const url = "a.html?a=1&b=2&c=3";
queryParam("a", url);
queryParam("b", url);
Set URL parameters
const url = "a.html?a=1&b=2&c=3";
setParams(
{
a: "11111",
},
url
);
setParams(
{
b: "2222",
c: "3333",
d: "4444",
},
url
);
License
MIT © 2022 givebest