UNPKG

xi-2022

Version:

提供了格式化时间、HTMLEscape相关的功能

34 lines (28 loc) 884 B
## 安装 >npm i xi-2022 ## 导入 >const r=require('./xi-2022/') ## 格式化时间 ##### "提供了格式化时间、HTMLEscape相关的功能" ```js // 调用 time 对时间进行格式化 console.log(r.time(new Date()));//2022-10-12 16:51:19 ``` ## 转义 HTML 中的特殊字符 ```js // 带转换的 HTML 字符串 let a='<h3 title="abc">123&nbsp;<span>666&gt</span></h3>' // 调用 zy 方法进行转换 // 转换的结果 //&lt;h3 title=&quot;abc&quot;&gt;123&amp;nbsp;&lt;span&gt;666&amp;gt&lt;/span&gt;&lt;/h3&gt; console.log(r.zy(a)); ``` ## 还原 HTML 中的特殊字符 ```js // 待还原的 HTML 字符串 let b=r.zy(a) //&lt;h3 title=&quot;abc&quot;&gt;123&amp;nbsp;&lt;span&gt;666&amp;gt&lt;/span&gt;&lt;/h3&gt; console.log(r.zh(b)); // 输出的结果 <h3 title="abc">123&nbsp;<span>666&gt</span></h3> ``` ## 开源协议 > ISC