aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/url/tostring/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/url/tostring/index.html')
-rw-r--r--files/zh-cn/web/api/url/tostring/index.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/url/tostring/index.html b/files/zh-cn/web/api/url/tostring/index.html
new file mode 100644
index 0000000000..090bdf2be1
--- /dev/null
+++ b/files/zh-cn/web/api/url/tostring/index.html
@@ -0,0 +1,63 @@
+---
+title: URL.toString()
+slug: Web/API/URL/toString
+tags:
+ - API
+ - URL
+ - 参考
+ - 字符串
+ - 方法
+translation_of: Web/API/URL/toString
+---
+<div>{{ApiRef("URL API")}}</div>
+
+<p><strong><code>URL.toString()</code></strong> 字符串化方法返回一个包含完整 URL 的 {{domxref("USVString")}}。它的作用等同于只读的 {{domxref("URL.href")}}。</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>string</em> = <em>url</em>.toString();</pre>
+
+<h3 id="参数">参数</h3>
+
+<p>无。</p>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个{{domxref("USVString")}}。</p>
+
+<h2 id="参考">参考</h2>
+
+<pre class="brush: js"><span class="message-body-wrapper"><span class="message-flex-body"><span class="devtools-monospace message-body"><span class="cm-keyword">const</span> <span class="cm-def">url</span> <span class="cm-operator">=</span> <span class="cm-keyword">new</span> <span class="cm-variable">URL</span>(<span class="cm-string">"https://developer.mozilla.org/en-US/docs/Web/API/URL/toString"</span>);
+<span class="cm-variable">url</span>.<span class="cm-property">toString</span>() // 应当返回字符串形式的 URL</span></span></span>
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('URL', '#URL-stringification-behavior', 'stringifier')}}</td>
+ <td>{{Spec2('URL')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.URL.toString")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>父级接口 {{domxref("URL")}}。</li>
+</ul>