url.search


获取和设置网址的序列化的查询部分。

【Gets and sets the serialized query portion of the URL.】

const myURL = new URL('https://example.org/abc?123');
console.log(myURL.search);
// Prints ?123

myURL.search = 'abc=xyz';
console.log(myURL.href);
// Prints https://example.org/abc?abc=xyz 

在分配给 search 属性的值中出现的任何无效 URL 字符都将被 百分比编码 编码。哪些字符需要进行百分比编码的选择,可能会与 url.parse()url.format() 方法生成的结果略有不同。

【Any invalid URL characters appearing in the value assigned the search property will be percent-encoded. The selection of which characters to percent-encode may vary somewhat from what the url.parse() and url.format() methods would produce.】