1.0.1 • Published 2 years ago

huangluoxuan-tools v1.0.1

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

安装

npm install huangluoxuan-tools

导入

const huangluoxuan = require('huangluoxuan-tools')

格式时间

//调用dateFormat 
const str = huangluoxuan.dateFormat(new Date())
//结果 2020-04-04 17:20:32
console.log(str)

转义HTML中特殊的字符

//调用htmlEscape进行转换
const htmlStr = '<h1 title="abc">测试&nbsp;</h1>'
//结果 &lt;h1 title=&quot;abc&quot;&gt;测试&amp;nbsp;&lt;/h1&gt;
const str1 = huangluoxuan.htmlEscape(htmlStr)

还原HTML中特殊的字符

//待还原的HTML字符串
const str2 = huangluoxuan.htmlUnEscape(str1)
//输出结果 <h1 title="abc">测试&nbsp;</h1>
console.log(str2)

开源协议

ISC