1.0.0 • Published 3 years ago
ithema-hero v1.0.0
安装
npm intall ithema-hero
导入
const ithema=require('ithema-hero')
格式化时间
//调用dateFormat()方法对时间格式化
const dt = ithema.dateFormat(new Date())
//结果 2021-01-08 15:36:13
console.log(dt);
转义html中的特殊字符
//待转换的html字符串
const str = '<h1 title="abc">这是一个h1标签<span>123 </span></h1>'
//调用htmlEscape()方法转换
const newStr = ithema.htmlEscape(str)
//结果 <h1 title="abc">这是一个h1标签<span>123amp;nbsp;</span></h1>
console.log(newStr);
还原html中的特殊字符
//带还原的html字符串 newStr
//调用htmlUnEscape()方法转换
const str2 = ithema.htmlUnEscape(newStr)
//结果 <h1 title="abc">这是一个h1标签<span>123 </span></h1>
console.log(str2);
开源协议
ISC
1.0.0
3 years ago