1.0.0 • Published 2 years ago

itheima_wm v1.0.0

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

安装

npm i itheima_wm

##导入

const itheima = require('./index')

格式化时间

// 调用 dateFormat 对时间进行格式化
const date = itheima.dateFormat(new Date())
console.log(date);
//结果  2022-09-21  09-35-39

转译HTML中的特殊字符

const str = '<h4 title="abc">这是h4标签<span>123&nbsp;</span></h4>'

const htmlstr = itheima.htmlEscape(str)

console.log(htmlstr);
// 结果 &lt;h4 title=&quot;abc&quot;&gt;这是h4标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;

还原 HTML 中的特殊字符

const str1 = '&lt;h4 title=&quot;abc&quot;&gt;这是h4标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;'
const res = itheima.htmlUnEscape(str1)
console.log(res);

开源协议

ISC