aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/url/tojson
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/url/tojson
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/url/tojson')
-rw-r--r--files/zh-cn/web/api/url/tojson/index.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/url/tojson/index.html b/files/zh-cn/web/api/url/tojson/index.html
new file mode 100644
index 0000000000..73e4eec754
--- /dev/null
+++ b/files/zh-cn/web/api/url/tojson/index.html
@@ -0,0 +1,54 @@
+---
+title: URL.toJSON()
+slug: Web/API/URL/toJSON
+tags:
+ - URL.toJSON()
+translation_of: Web/API/URL/toJSON
+---
+<p>{{APIRef("URL API")}}</p>
+
+<p>{{domxref("URL")}}接口的 <strong>toJSON() </strong>方法返回一个{{domxref("USVString")}},其中包含一个序列化的URL版本,尽管在实践中它似乎与{{domxref("URL.toString()")}}有相同的效果。</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="notranslate">const <em>href</em> = <em>url</em>.toJSON()</pre>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个 {{domxref("USVString")}}.</p>
+
+<h2 id="例子">例子</h2>
+
+<pre class="notranslate">const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
+url.toJSON(); // 应该以字符串形式返回URL</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', '#dom-url-tojson', 'toJSON()')}}</td>
+ <td>{{Spec2('URL')}}</td>
+ <td>初步定义.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容">浏览器兼容</h2>
+
+<div class="hidden">
+<p>本页的兼容性表是由结构化数据生成的。如果你想为数据做出贡献,请查看<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> ,并向我们发送拉取请求。</p>
+</div>
+
+<p>{{Compat("api.URL.toJSON")}}</p>
+
+<div id="compat-desktop"></div>
+
+<div id="compat-mobile"></div>