1.0.0 • Published 5 years ago
mydata-tools v1.0.0
安装
npm install my-tools
导入
const mytools = require('./mytools');
格式化时间
const dt = mytools.dateFormate(new Date());
console.log(dt);
// 结果
2020-09-10 15:40:04
html转义特殊字符
const html = '<h1 title="abc">这是标题啊<span>123 </span></h1>';
//调用HTMLEscape进行转换
const str = mytools.HTMLEscape(html);
console.log(str);
// 结果
<h1 title="abc">这是标题啊<span>123&nbsp;</span></h1>
还原html特殊字符
//调用HTMLUNEscape进行还原
const str2 = mytools.HTMLUNEscape(str);
console.log(str2);
// 结果
<h1 title="abc">这是标题啊<span>123 </span></h1>
开源协议
ISC
1.0.0
5 years ago