From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/decodeuricomponent/index.html | 150 +++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html b/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html new file mode 100644 index 0000000000..07070206e4 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html @@ -0,0 +1,150 @@ +--- +title: decodeURIComponent() +slug: Web/JavaScript/Reference/Global_Objects/decodeURIComponent +tags: + - JavaScript + - URI + - 统一资源标识符 + - 解码 +translation_of: Web/JavaScript/Reference/Global_Objects/decodeURIComponent +--- +
{{jsSidebar("Objects")}}
+ +

decodeURIComponent() 方法用于解码由 {{jsxref("encodeURIComponent")}} 方法或者其它类似方法编码的部分统一资源标识符(URI)。

+ +

语法

+ +
decodeURIComponent(encodedURI)
+ +

参数

+ +
+
encodedURI
+
编码后的部分 URI
+
+ +

返回值

+ +

一个解码后的统一资源标识符(URI)字符串,处理前的URI经过了给定格式的编码。

+ +

异常

+ +

当该方法使用不当时,将会抛出一个{{jsxref("URIError")}}(格式错误的URI序列)异常。

+ +

描述

+ +

将已编码 URI 中所有能识别的转义序列转换成原字符。

+ +

示例

+ +

解码一个西里尔字母的URL

+ +
decodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
+// "JavaScript_шеллы"
+
+ +

捕捉异常

+ +
try {
+  var a = decodeURIComponent('%E0%A4%A');
+} catch(e) {
+  console.error(e);
+}
+
+// URIError: malformed URI sequence
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
规范状态备注
{{SpecName('ES3')}}{{Spec2('ES3')}}初始定义
{{SpecName('ES5.1', '#sec-15.1.3.2', 'decodeURIComponent')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-decodeuricomponent-encodeduricomponent', 'decodeURIComponent')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-decodeuricomponent-encodeduricomponent', 'decodeURIComponent')}}{{Spec2('ESDraft')}} 
+ +

浏览器兼容性

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
基础功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
基础功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

相关链接

+ + + +

+ +

-- cgit v1.2.3-54-g00ecf