itzyb-tools

1.0.0 • Public • Published

安装

npm install itzyb-tools

导入

const itzyb = require('itzyb-tools')

格式化时间

// 测试时间
const newDateStr = dt.dateFormat(new Date())
console.log(newDateStr)
// 结果 2022-07-16 17:09:21

转义 HTML 中的特殊字符

//测试HTML字符
const htmlStr = '<h1 style="red">张自律<span>123</span></h1>'
const str = dt.htmlEscape(htmlStr)
console.log(str)
//结果 &lt;h1 style=&quot;red&quot;&gt;张自律&lt;span&gt;123&lt;/span&gt;&lt;/h1&gt;

转义还原 HTML 中的特殊字符

const str2 = dt.htmlUnEscape(str)
console.log(str2)
// 结果 <h1 style="red">张自律<span>123</span></h1>

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i itzyb-tools

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

2.46 kB

Total Files

5

Last publish

Collaborators

  • zhangyubiao