1.0.0 • Published 10 months ago

itheima-jdx v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

安装

npm i ltheima-jdh

导入

const itheima = require('itheima-jdh')

格式化时间

const ss = itheima.dateFormat(new Date())
// 结果2023-07-03 09:10:18

转义 HTML 中特殊字符

// 待转化的html字符串
const htmlst = '<h1>这是一段文字&nbsp<span>123123</span></h1>'
// 调用htmlesape方法进行转换
const nothtml = itheima.HTMLEscape(htmlst)
// 转换的结果为&lt;h1&gt;这是一段文字&amp;nbsp&lt;span&gt;123123&lt;/span&gt;&lt;/h1&gt;
console.log(nothtml)

还原 HTML 中特殊字符

// 待还原的html字符串
const html = itheima.htmlhtml(nothtml)
// 输出结果<h1>这是一段文字&nbsp<span>123123</span></h1>
console.log(html)

开源协议

ISC

1.0.0

10 months ago