1.0.0 • Published 2 years ago

itheimajw002 v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装方式

npm  install itheimajw001

导入方式

const it = require('./itheimajw001')

格式化时间

//调用dataFormat 对时间进行格式化
const date = it.dataFormat(new Date())
console.log(date)
//结果  2022-08-06 09:40:17

转义 HTML 中的特殊字符

//带转换的html字符串
const htmlstr = '<h1>哈哈哈&少喝"奶茶"多睡觉</h1>'
//调用htmlescape 方法进行转换
const str = it.HTMLEscape(htmlstr)
console.log(str)
//结果 &lt;h1&gt;哈哈哈&amp;少喝&quot;奶茶&quot;多睡觉&lt;/h1&gt;

还原字符

//带还原的html字符串
const htmlstrT = '&lth1&gt哈哈哈&amp少喝&quot奶茶&quot多睡觉&lt/h1&gt'
const str2 = it.HTMLUnEscape(htmlstrT)
console.log(str2)
// 结果 <h1>哈哈哈&amp少喝"奶茶"多睡觉</h1>

开源协议

ISC