0.0.1 • Published 4 years ago

zy-utils-112233 v0.0.1

Weekly downloads
53
License
MIT
Repository
-
Last release
4 years ago

安装

npm i zy-utils

导入

const utils = require('zy-utils')

格式化时间

// 调用 dateFormat 对时间进行格式化
const dt = utils.dateFormat('2021-2-21')
// 结果  2021-02-21 00:00:00
console.log(dt);

转义 HTML 中的特殊字符

// 带转换的 HTML 字符串
const res = utils.htmlEscape('<div style="">123123&nbsp;123123</div>')
// 转换的结果 &lt;div style=&quot;&quot;&gt;123123&amp;nbsp;123123&lt;/div&gt;
console.log(res)

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
const res1 = utils.unHtmlEscape('&lt;div style=&quot;&quot;&gt;123123&amp;nbsp;123123&lt;/div&gt;')
// 输出的结果 <div style="">123123&nbsp;123123</div>
console.log(res1)

开源协议

MIT