Skip to content

Commit ff0ac34

Browse files
update
1 parent c2c9c6a commit ff0ac34

15 files changed

+273
-93
lines changed
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title></title>
8+
</head>
9+
<body>
10+
<script>
11+
async function test () {
12+
await promiseFunction()
13+
// ...
14+
}
15+
</script>
16+
</body>
17+
</html>
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,30 @@
1010
// 数据传递常需要编码后传递,接收还需反编译,推荐使用encodeURIComponent
1111
var url = "http://www.csxiaoyao.com?username='CS逍遥剑仙'&password='19931128'";
1212

13-
// 【escape & unescape
13+
// 【 escape & unescape 】 !!!URL编码勿使用此方法
1414
console.log(escape(url));// 编码 http%3A//www.csxiaoyao.com%3Fusername%3D%27CS%u900D%u9065%u5251%u4ED9%27%26password%3D%2719931128%27
1515
console.log(unescape(escape(url)));// 解码 http://www.csxiaoyao.com?username='CS逍遥剑仙'&password='19931128'
1616

17-
// 【encodeURIComponent & decodeURIComponent】【推荐】
17+
// 【 encodeURIComponent & decodeURIComponent 】【推荐】如果URI中含分隔符如 ? 和 #,应使用encodeURIComponent
1818
console.log(encodeURIComponent(url));// 编码 http%3A%2F%2Fwww.csxiaoyao.com%3Fusername%3D'CS%E9%80%8D%E9%81%A5%E5%89%91%E4%BB%99'%26password%3D'19931128'
1919
console.log(decodeURIComponent(encodeURIComponent(url)));// 解码 http://www.csxiaoyao.com?username='CS逍遥剑仙'&password='19931128'
2020

21-
// 【encodeURI & decodeURI
21+
// 【 encodeURI & decodeURI 】如果URI中含分隔符如 ? 和 #,应使用encodeURIComponent
2222
console.log(encodeURI(url));// 编码 http://www.csxiaoyao.com?username='CS%E9%80%8D%E9%81%A5%E5%89%91%E4%BB%99'&password='19931128'
2323
console.log(decodeURI(encodeURI(url)));// 解码 http://www.csxiaoyao.com?username='CS逍遥剑仙'&password='19931128'
2424

2525
// 【区别】
2626
// 三种方法都不会对 ASCII 字母、数字和规定的特殊 ASCII 标点符号进行编码,其余都替换为十六进制转义序列
27-
// 【escape & unescape】
27+
28+
// 【 escape & unescape 】
2829
// escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z
2930
// 对字符串全部进行转义编码,ECMAScript v3 反对使用该方法,对URL编码勿使用此方法
30-
// 【encodeURIComponent & decodeURIComponent】
31+
32+
// 【 encodeURIComponent & decodeURIComponent 】
3133
// encodeURIComponent不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z
3234
// 传递参数时需使用encodeURIComponent,组合的url才不会被#等特殊字符截断
33-
// 【encodeURI & decodeURI】
35+
36+
// 【 encodeURI & decodeURI 】
3437
// encodeURI不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z
3538
// 进行url跳转时可以整体使用encodeURI,如果URI中含分隔符如 ? 和 #,应使用encodeURIComponent
3639

0 commit comments

Comments
 (0)