itcc-tools

1.0.1 • Public • Published

安装

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

Readme

Keywords

Package Sidebar

Install

npm i itcc-tools

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

2.75 kB

Total Files

5

Last publish

Collaborators

  • blanchecc