1.0.0 • Published 3 years ago
my-helps v1.0.0
安装
npm install my-helps
导入
const dt = require('../node.js/my-helps')
格式化时间
//调用dataFormat 对时间进行格式化
const n = dt.dataFormat(new Date())
//结果 2022-05-05 20:28:04
console.log(n);
转义 HTML中的特殊字符
//待转义的 HTML字符串
const htmlstr = '<h1 title="abc">这是h标签<span>123 </span></h1>'
// 调用 htmlEscape 方法进行转换
const m= dt.htmlEscape(htmlstr)
// 结果 <h1 title="abc">这是h标签<span>123&nbsp;</span></h1>
console.log(m);
还原 HTML中的特殊字符
//待还原的 HTML 字符串
const nn = dt.htmlUnEscape(m)
// 结果 <h1 title="abc">这是h标签<span>123 </span></h1>
console.log(nn);
开源协议
ISC
1.0.0
3 years ago