3.6.9 • Published 2 years ago

itgaodeif v3.6.9

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

安装

npm install itgaodeif-tools

导入

const itgaodeif = require('itgaodeif-tools')

格式化时间

// 调用 dateFormat 对时间进行格式化
const dtStr = itgaodeif.dateFormat(new Date())
// 结果 2022-04-17 14:04:11
console.log(dtStr) 

转义 HTML 中的特殊字符

// 待转换的 HTML 字符串
const htmlstr = '<h1 title="abc">阿哲<span>123&nbsp;</span></h1>'
// 调用 htmlEscape 方法进行转换
const str = itgaodeif.htmlEscape(htmlstr)
// 转换结果 &lt;h1 title=&quot;abc&quot;&gt;阿哲&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str)

还原 HTML 中的特殊字符

// 待转换的 HTML 字符串
const htmlStr = '&lt;h1 title=&quot;abc&quot;&gt;阿哲&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;'
// 调用 htmUnlEscape 方法进行还原
const str = itgaodeif.htmlUnEscape(htmlstr)
// 转换结果 <h1 title="abc">阿哲<span>123&nbsp;</span></h1>
console.log(Str)

开源协议

ISC