aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/urlsearchparams/set
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/urlsearchparams/set
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/urlsearchparams/set')
-rw-r--r--files/zh-cn/web/api/urlsearchparams/set/index.html107
1 files changed, 107 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/urlsearchparams/set/index.html b/files/zh-cn/web/api/urlsearchparams/set/index.html
new file mode 100644
index 0000000000..6790f615e7
--- /dev/null
+++ b/files/zh-cn/web/api/urlsearchparams/set/index.html
@@ -0,0 +1,107 @@
+---
+title: URLSearchParams.set()
+slug: Web/API/URLSearchParams/set
+translation_of: Web/API/URLSearchParams/set
+---
+<p>{{ApiRef("URL API")}}{{SeeCompatTable}} </p>
+
+<p>{{domxref("URLSearchParams")}}接口的set()方法用于设置和搜索参数相关联的值。如果设置前已经存在匹配的值,该方法会删除多余的,如果将要设置的值不存在,则创建它</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">URLSearchParams.set(name, value)</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt>键名</dt>
+ <dd>将要设置的参数的健值名。</dd>
+ <dt>参数值</dt>
+ <dd>所要设置的参数值。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>Void</p>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: js">let url = new URL('https://example.com?foo=1&amp;bar=2');
+let params = new URLSearchParams(url.search.slice(1));
+
+//Add a third parameter.
+params.set('baz', 3);
+</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('URL', '#dom-urlsearchparams-set', "set()")}}</td>
+ <td>{{Spec2('URL')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(49.0)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(49.0)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatChrome(49.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>