1.0.0 • Published 1 year ago

it-zjs-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

npm install it-tools

导入

const itTools = require('it-tools')

格式化时间

// 调用dateFormat 对时间进行格式化
const dateS = itTools.dateFormat(new Date()) 
console.log(dateS)

转义HTML

// 待转换的 HTML 字符串
const  htmlStr = itTools.htmlEscape('<h1 style="color:red;"> 这是测试转义的&nbsp;</h1>')
 // 转换结果 &lt;h1 style=&quot;color:red;&quot;&gt; 这是测试转义的&amp;nbsp;&lt;/h1&gt;
console.log(htmlStr)

还原HTML中的特殊字符

// 待还原的 HTML 字符串
const Unhtml= itTools.htmlUnEscape(htmlStr)
 // 还原结果 <h1 style="color:red;"> 这是测试转义的&nbsp;</h1>
console.log(Unhtml)
1.0.0

1 year ago