1.0.1 • Published 2 years ago

itcc-tools v1.0.1

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

安装

npm install itcc-tools

导入

const dt = require('./itcc-tools')

格式化时间

// 通过dateFormat函数对时间进行格式化
const dtStr = dt.dateFormat(new Date())
// 输出结果:2022-03-16  21:36:37
console.log(dtStr)

转义HTML中的特殊字符

// 通过调用 htmlEscape 方法对待转换的HTML字符串进行转义
const htmlStr = dt.htmlEscape('<h1 title="abc">这是h1标签</h1>')
// 输出:&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;/h1&gt;  
console.log(htmlStr)

还原HTML字符串

// 通过调用 htmlUnEscape 方法还原html字符串
const htmlUnStr = dt.htmlUnEscape('&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;/h1&gt;')
// 输出:<h1 title="abc">这是h1标签</h1>
console.log(htmlUnStr)

开源协议

ISC

1.0.1

2 years ago

1.0.0

2 years ago