1.1.1 • Published 29 days ago
wjx-tools v1.1.1
##安装
npm install wjx-tools
##导入
const wjx = require("./wjx-tools/index");
##格式化时间
// 格式化时间代码
const date = wjx.dateFormat(new Date());
// 结果 2024-04-25 18:02:51
console.log(date);
##转义 HTML 字符
//待转义的字符
const htmlStr = '<h1 title="abc">这是h1标签<span>1234 </span></h1>';
//调用htmlEscape进行转义
const str = wjx.htmlEscape(htmlStr);
//结果 <h1 title="abc">这是h1标签<span>1234&nbsp;</span></h1>
console.log(str);
##还原 HTML 字符
//待还原的字符
const str2 = wjx.htmlUnEscape(str);
//结果 <h1 title="abc">这是h1标签<span>1234 </span></h1>
console.log(str2);
##开源协议 ISC