1.1.1 • Published 2 years ago

itheima-tools-zzw v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

npm install itheima-tools-zzw

导入

const itheima = require("itheima-tools-zzw");

格式化时间

// 调用dataFormat()方法
const dtStr = m1.dateFormat(new Date());
// 格式化时间的功能
console.log(dtStr); // 2022-09-27 17:13:30

转换 HTML 中的特殊字符

// 待转换的  html 字符
const htmlStr = `<h1 title="擦"><p>怕</p><span>帝</span><strong>"秋夜长&&"</strong></h1>`;
// 调用 htmlEscape 方法进行转换
const htStr = m1.htmlEscape(htmlStr);
console.log(htStr);
// 结果 :   &lth1 title=&quot擦&quot&gt&ltp&gt怕&lt/p&gt&ltspan&gt帝&lt/span&gt&ltstrong&gt&quot秋夜长&amp&amp&quot&lt/strong&gt&lt/h1&gt

还原 HTML 标签

const Uhtml = m1.htmlUnEscape(htStr);
console.log(Uhtml);
// 输出 :  <h1 title="擦"><p>怕</p><span>帝</span><strong>"秋夜长&&"</strong></h1>

开源协议

ISC

1.1.1

2 years ago

1.0.1

2 years ago

0.0.1

2 years ago

1.0.0

2 years ago