1.0.1 • Published 3 years ago
itwangzi-tools2 v1.0.1
安装
npm install itwangzi-tools2
导入
//调用 dateFormat 对时间标准化
const dtStr=it.dateFormat(new Date())
//结果 2022-03-19 15:49:01
console.log(dtStr)
转义 HTML 中的特殊字符
//带转换的 HTML 字符串
const htmlstr='<h1 title="abc">这是标签<span>123 </span></h1>'
//调用 htmlEscape 方法进行转换
const str=it.htmlEscape(htmlstr)
//结果 <h1 title="abc">这是标签<span>123&nbsp;</span></h1>
console.log(str)
还原 HTML 字符串
//调用 htmlUnEscape 方法进行还原
const str2=it.htmlUnEscape(str)
//结果 <h1 title="abc">这是标签<span>123 </span></h1>
console.log(str2)
开源协议
ISC
1.0.1
3 years ago