微信扫一扫打赏支持

尚硅谷js---23、unicode编码

尚硅谷js---23、unicode编码

一、总结

一句话总结:

在js中用 \u四位编码 使用,在html中用 &#编码; 使用。

\u四位编码:比如console.log("\u2620");
&#编码; 这里的编码需要的是10进制:比如 h1 style="font-size: 200px;">&#9760;</h1

 

1、js代码中如何使用unicode编码?

\u四位编码:比如console.log("\u2620");

 

2、html代码中如何使用unicode编码?

&#编码; 这里的编码需要的是10进制:比如 h1 style="font-size: 200px;">&#9760;</h1

 

 

 

二、unicode编码

博客对应课程的视频位置:

 

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title></title>
 6         <script type="text/javascript">
 7             
 8             /*
 9              * 在字符串中使用转义字符输入Unicode编码
10              *     \u四位编码
11              */
12             console.log("\u2620");
13             
14         </script>
15     </head>
16     <body>
17         
18         <!--在网页中使用Unicode编码
19             &#编码; 这里的编码需要的是10进制
20         -->
21         <h1 style="font-size: 200px;">&#9760;</h1>
22         <h1 style="font-size: 200px;">&#9856;</h1>
23         
24     </body>
25 </html>

 

 

 

 

 

 
posted @ 2020-02-26 13:59  范仁义  阅读(146)  评论(0)    收藏  举报