From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/url/tojson/index.html | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 files/zh-cn/web/api/url/tojson/index.html (limited to 'files/zh-cn/web/api/url/tojson') 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 +--- +

{{APIRef("URL API")}}

+ +

{{domxref("URL")}}接口的 toJSON() 方法返回一个{{domxref("USVString")}},其中包含一个序列化的URL版本,尽管在实践中它似乎与{{domxref("URL.toString()")}}有相同的效果。

+ +

{{AvailableInWorkers}}

+ +

语法

+ +
const href = url.toJSON()
+ +

返回值

+ +

一个 {{domxref("USVString")}}.

+ +

例子

+ +
const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
+url.toJSON(); // 应该以字符串形式返回URL
+ +

说明

+ + + + + + + + + + + + + + +
说明状态评论
{{SpecName('URL', '#dom-url-tojson', 'toJSON()')}}{{Spec2('URL')}}初步定义.
+ +

浏览器兼容

+ + + +

{{Compat("api.URL.toJSON")}}

+ +
+ +
-- cgit v1.2.3-54-g00ecf