UNPKG

tools-zhaoshuaiqi

Version:

提供了格式化时间,HTML.Escape相关的功能

40 lines (34 loc) 969 B
## 安装 ``` npm install tools-zhaoshuaiqi ``` ## 导入 ···js const itheima = require('tools-zhaoshuaiqi') ··· ## 格式化时间 ···js //调用dateformat对时间进行可视化 const dt = itheima.dataFormat(new Date()) //2025-05-20 10:06:41 console.log(dt); ··· ## 转义HTML中的特殊字符 ···js //待转换的HTML字符串 <!-- const htmstr = '<h1 title="abs">这是h1标签<span>123&nbsp;</span></h1>' --> //调用htmlEscape对特殊字符进行转义 <!-- const str1=itheima.htmlEscape(htmstr) --> //结果 &lt;h1 title=&quot;abs&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt; <!-- console.log("\n",str1); --> ··· ## 还原HTML中的特殊字符 ···js //待还原的HTML字符串 <!-- const str2 = itheima.htmlUnEscape(str1); --> //输出的结果 <!-- <h1 title="abs">这是h1标签<span>123&nbsp;</span></h1> --> console.log("\n",str2); ··· ## 开源协议 ISC