1.0.0 • Published 4 years ago
tujun-niubi v1.0.0
##安装
npm install tujun-niubi
##导入方式 js
const niubi = require("tujun-niubi");
##格式化时间
// 调用dateFormat函数来格式化时间
const dt = niubi.dateFormat(new Date());
// 结果为2021-02-27 14:12:20
console.log(dt);
##转义 HTML 中的特殊字符
// 待转换为html字符串
const abc = '<div style="color: red">123123 <span>abcdefg</span></div>';
// 调用转换的htmlEscape函数进行转换
const str = niubi.htmlEscape(abc);
// 结果为<div style="color: red">123123&nbsp;<span>abcdefg</span></div>
console.log(str);
##还原 HTML 中的特殊字符
// 待还原的html字符串
const efg =
"<div style="color: red">123123&nbsp;<span>abcdefg</span><";
// 调用还原的unhtmlEscape函数进行还原
const str2 = niubi.unhtmlEscape(str);
// 结果为<div style="color: red">123123 <span>abcdefg</span></div>
console.log(str2);
##开源协议 ISC
1.0.0
4 years ago