1.0.0 • Published 2 years ago

itheima_tools_zjd v1.0.0

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

安装

npm install itheima_tools_zjd

导入

const it = require('./itheima_tools_zjd')

格式化时间

//调用dateFormat 对时间进行格式化
const dt = it.dataFormat(new Date())
//2022-08-13 19:47:56
console.log(dt);

转义HTML中的特殊字符

const htmlstr = '<h1 style="">这是h1标签<span>123&nbsp</span></h1>'
const nStr = it.htmlEscape(htmlstr)
// &lt;h1 style=&quot;&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp&lt;/span&gt;&lt;/h1&gt;
console.log(it.htmlEscape(htmlstr)); 

还原HTML中的特殊字符

const oHtml = it.htmlUnEscape(nStr)
// <h1 style="">这是h1标签<span>123&nbsp</span></h1>
console.log(oHtml);

开源协议

ISC