使用URI获取链接和参数
https://medialize.github.io/URI.js/docs.html#accessors-hostname
这个是参考文档的地址
var uri = new URI("http://example.org/foo/hello.html?foo=bar&bar=baz");
// get search
uri.search(); // returns string "?foo=bar&bar=baz" (leading ?)
// get query
uri.query(); // returns string "foo=bar&bar=baz" (no leading ?)
// .query() and .search() behave the same for the following:
// set search
uri.search("?foo=bar&bar=baz"); // returns the URI instance for chaining
uri.search("foo=bar&bar=baz"); // returns the URI instance for chaining
// uri == "http://example.org/bar/world.html?foo=bar&bar=baz"
// remove query
uri.search(""); // returns the URI instance for chaining
// uri == "http://example.org/bar/world.html"
// get data map:
uri.search(true); // returns { foo: "bar", hello : ["world", "mars"] }
// set data map:
uri.search({ foo: "bar", hello : ["world", "mars"] });
// uri == "http://example.org/bar/world.html?foo=bar&hello=world&hello=mars"
// overwrite data through callback
uri.search(function(data) {
return { hello : "world" };
});
// uri == "http://example.org/bar/world.html?hello=world"
// augment data through callback
uri.search(function(data) {
data.foo = "bar";
});
// uri == "http://example.org/bar/world.html?hello=world&foo=bar"
// CAUTION: beware of arrays, the following are not quite the same
// If you're dealing with PHP, you probably want the latter…
uri.search("?foo=bar&bar=baz");
uri.search("?foo=bar[]&bar[]=baz");