cjj-tools

1.0.0 • Public • Published

安装

npm install cjj-tools

导入

const cjj_tools = require('cjj-tools')

格式化时间

const date = cjj_tools.formatDate(new Date)
// 转换后的结果: 2022-12-28 23:18:51

转换 HTML 字符串中的特殊字符

// 转换前的HTML字符串
const htmlStr = '<h1 style="">asdfasd&nbsp;</h1>'
// 转换后的结果: &lt;h1 style=&quot;&quot;&gt;asdfasd&amp;nbsp;&lt;/h1&gt;
console.log(cjj_tools.htmlEscape(htmlStr));

还原 HTML 字符串中的特殊字符

// 转换前的字符串
const htmlUnStr = '&lt;h1 style=&quot;&quot;&gt;asdfasd&amp;nbsp;&lt;/h1&gt;'
// 转换后的结果: <h1 style="">asdfasd&nbsp;</h1>
console.log(cjj_tools.htmlUnEscape(htmlUnStr));

开源协议

ISC

Package Sidebar

Install

npm i cjj-tools

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

2.51 kB

Total Files

5

Last publish

Collaborators

  • cjjj37