1.0.0 • Published 5 years ago

itheima-case v1.0.0

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

安装

npm install npmCase

导入

const npmCase = require('npmCase')

格式化时间

//调用dateFormat 对时间进行格式化
const dt = npmCase.dateFormat(new Date())
//2020-09-10 09:46:25
console.log(dt)

转义 HTML 中的特殊字符

//测试html转义
const str = '<h1>这是个标签<span>123&nbsp;</span></h1>'
const newStr = npmCase.htmlEscape(str)
//转换结果: &lt;h1&gt;这是个标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(newStr)

还原 HTML 中的特殊字符

//测试还原html转义
const nt = npmCase.htmlUnEscape(newStr)
//转换结果: <h1>这是个标签<span>123&nbsp;</span></h1>
console.log(nt)

开源协议

ISC

1.0.0

5 years ago