We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL其实是一个很值得深入学习的东西,比如说url参数,url通信等等。
The text was updated successfully, but these errors were encountered:
这是一个或者url query参数的非常好用的一类。 可以传入的参数有:url.search, 序列,记录。
"?foo=1&bar=2"
[["foo", 1],["bar", 2]]
{"foo" : 1 , "bar" : 2}
var url = new URL('https://example.com?foo=1&bar=2'); var params = new URLSearchParams(url.search);// 生成一个URLSearchParams实例
URLSearchParams方法:
params.append('baz', 3);// Query String 为 "?foo=1&bar=2&baz=3"
params.delete('foo');//Query String 为 "?bar=2"
for(var pair of params.entries()){ console.log(pair[0]+ ', '+ pair[1]); // foo,1; bar,2 }
params.forEach((value, key)=>{ console.log(key, value);// foo 1; bar 2 })
params.get('foo');// 1
params.append('foo', '3'); params.getAll('foo');// ["1", "3"]
params.has('foo');// true
for(var key of params.keys()){ console.log(key); // foo bar }
params.set('foo', 0);// Query String 为 "?foo=0&bar=2"
params.set('foo', 3); params.sort()// Query String 为 "?bar=2&foo=3"
params.toString(); // "?foo=1&bar=2"
for(var value of params.values()){ console.log(value); // 1,3 }
Sorry, something went wrong.
No branches or pull requests
URL其实是一个很值得深入学习的东西,比如说url参数,url通信等等。
The text was updated successfully, but these errors were encountered: