itheima-chen-bzhan

9.9.9 • Public • Published

安装

npm install itheima-chen-bzhan

导入

const itheima = require('itheima-chen-bzhan')

格式化时间

// 调用 dateFormat 对时间进行格式化
const dtStr = itheima.dateFormat(new Date())
// 结果  2023-04-03 17:20:58
console.log(dtStr)

转义 HTML 中的特殊字符

// 带转换的 HTML 字符串
const htmlStr = '<h1 style="color:red">这是红色的h1<span>span</span></h1>'
// 调用 htmlEscape 方法进行转换
const str = itheima.htmlEscape(htmlStr)
// 转换的结果 &lt;h1 style=&quot;color:red&quot;&gt;这是红色的h1&lt;span&gt;span&lt;/span&gt;&lt;/h1&gt;
console.log(str)

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
const str2 = itheima.htmlUnEscape(str)
// 输出的结果 <h1 style="color:red">这是红色的h1<span>span</span></h1>
console.log(str2)

开源协议

ISC

Package Sidebar

Install

npm i itheima-chen-bzhan

Weekly Downloads

3

Version

9.9.9

License

ISC

Unpacked Size

2.75 kB

Total Files

5

Last publish

Collaborators

  • huafudie