1.0.0 • Published 2 years ago
itchangan-1 v1.0.0
安装
npm install itchangan-1
导入
const itchangan_1 = require('itchangan-1')
格式化时间
//调用 dateFormat 对时间进行格式化
const dtStr = itchangan_1.dateFormat(new Date())
//结果 2022-05-11 22:01:49
console.log(dtStr)
转义 HTML 中的特殊字符
//待转换的字符串
const htmlStr = '<h1 title="abc">这是 h1 标签<span>123&ndsp;</span></h1>'
//调用 HTMLEscape 进行转换
const HTMLStr = itchangan_1.HTMLEscape(htmlStr)
//结果 <h1 title="abc">这是 h1 标签<span>123&ndsp;</span></h1>
console.log(HTMLStr)
还原 HTML 中的特殊字符
//调用 HTMLUNEscape 进行还原
const HTMLUNEscape = itchangan_1.HTMLUNEscape(htmlStr)
//结果 <h1 title="abc">这是 h1 标签<span>123&ndsp;</span></h1>
console.log(HTMLUNEscape)
开源协议
ISC
1.0.0
2 years ago