1.0.0 • Published 1 year ago
lgh06 v1.0.0
安装
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> 2134</span></h1>'
//调用htmlescape 方法进行转换
const strs = lgh.HTMLstr(HTMLstr);
//转换的结果
style="color:red;">这是h1<span>&nbsp2134</span></h1>
console.log(strs)
还原html中的特殊字符
//待还原的html字符串
const haiyuan = lgh.HTMLhaiyuan(strs)
//输出的结果<h1 style="color:red;">这是h1<span> 2134</span></h1>
console.log(haiyuan);
开源协议
ISC
1.0.0
1 year ago