1.0.1 • Published 2 years ago
htf-tools v1.0.1
安装
npm install htf-tools
导入
const htf = require('htf-tools')
格式化时间
//调用dateForme 对时间格式化
const timestr = HTF.dateFormat(new Date())
//结果:2022-04-18 19:29:32
console.log(timestr)
转义HTML 中的特殊字符
//带转化的字符串
const html = '<h1 title="ab">这是h1标签<span>123#nbsp</span></h1>'
//调用htmlEacape 方法进行转化
const htmlstr = HTF.htmlEscape(html)
//转换结果:<h1 title="ab">这是h1标签<span>123#nbsp</span></h1>
console.log(htmlstr)
还原HTML 中的特殊字符
//还原HTML字符串
const htmlstr2 = HTF.htmlunEscape(htmlstr)
//转换结果:<h1 title="ab">这是h1标签<span>123#nbsp</span></h1>
console.log(htmlstr2)
开源协议
ISC