1.1.1 • Published 29 days ago

wjx-tools v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
29 days ago

##安装

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&nbsp;</span></h1>';
//调用htmlEscape进行转义
const str = wjx.htmlEscape(htmlStr);
//结果  &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;1234&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str);

##还原 HTML 字符

//待还原的字符
const str2 = wjx.htmlUnEscape(str);
//结果 <h1 title="abc">这是h1标签<span>1234&nbsp;</span></h1>
console.log(str2);

##开源协议 ISC

1.1.1

29 days ago

1.0.0

2 years ago