1.0.0 • Published 1 year ago

lgh06 v1.0.0

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

安装

npm install lgh-06

导入

const lgh = require('lgh-06')

格式化时间

//调用dateFormat对时间进行格式化
const str = lgh.dateFormat(new Date())
console.log(str);
//结果 2023:03:25 21:33:36

转义HTML中的特殊字符

//带转换的HTML字符串
const HTMLstr = '<h1 style="color:red;">这是h1<span>&nbsp2134</span></h1>'
//调用htmlescape 方法进行转换
const strs = lgh.HTMLstr(HTMLstr);
//转换的结果 
style=&quot;color:red;&quot;&gt;这是h1&lt;span&gt;&amp;nbsp2134&lt;/span&gt;&lt;/h1&gt;
console.log(strs)

还原html中的特殊字符

//待还原的html字符串
const haiyuan = lgh.HTMLhaiyuan(strs)
//输出的结果<h1 style="color:red;">这是h1<span>&nbsp2134</span></h1>
console.log(haiyuan);

开源协议

ISC