1.0.0 • Published 2 years ago
itheimajw002 v1.0.0
安装方式
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)
//结果 <h1>哈哈哈&少喝"奶茶"多睡觉</h1>
还原字符
//带还原的html字符串
const htmlstrT = '<h1>哈哈哈&少喝"奶茶"多睡觉</h1>'
const str2 = it.HTMLUnEscape(htmlstrT)
console.log(str2)
// 结果 <h1>哈哈哈&少喝"奶茶"多睡觉</h1>
开源协议
ISC
1.0.0
2 years ago