zimu-tools

1.0.2 • Public • Published

安装

npm install zimu-tools

导入

const zimu = require("zimu-tools");

格式化时间

const dtStr = zimu.dateFormat(new Date());
console.log(dtStr);

// 结果 2022-01-14 22:48:10

转义 HTML 中的特殊字符

let htmlStr = '<h1 class="title">这是h1标签<span>&nbsp;</span></h1>';
const str = zimu.htmlEscape(htmlStr);
console.log(str);

// 结果 &lt;h1 class=&quot;title&quot;&gt;这是h1标签&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原 HTML 中的特殊字符

let str1 = "&lt;h1 class=&quot;title&quot;&gt;这是h1标签&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;";
let str2 = zimu.htmlUnEscape(str1);
console.log(str2);

// 结果 <h1 class="title">这是h1标签<span>&nbsp;</span></h1>

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i zimu-tools

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

2.86 kB

Total Files

6

Last publish

Collaborators

  • bluewoods