--- title: URLSearchParams.toString() slug: Web/API/URLSearchParams/toString translation_of: Web/API/URLSearchParams/toString ---
{{ApiRef("URL API")}}{{SeeCompatTable}}
{{domxref("URLSearchParams")}} 接口的toString()方法 返回适用在URL中的查询字符串。
URLSearchParams.toString()
字符串
let url = new URL('https://example.com?foo=1&bar=2'); let params = new URLSearchParams(url.search.slice(1)); //Add a second foo parameter. params.append('foo', 4); console.log(params.toString()); //Prints 'foo=1&bar=2&foo=4'.
Specification | Status | Comment |
---|---|---|
{{SpecName('URL', '#urlsearchparams-stringification-behavior', "toString()")}} | {{Spec2('URL')}} | Initial definition. Appears in the IDL as stringifier . |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(49.0)}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatChrome(49.0)}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatChrome(49.0)}} |