1.0.0 • Published 2 years ago

itheima-tools-wxq v1.0.0

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

安装

npm install itheima-tools-wxq

导入

const itheima = require('itheima-tools')

格式化时间

let dtStr = itheima.dateFormat(new Date())
console.log(dtStr)
// result:
// 2022-4-11 23:34

转义html中的特殊字符

let htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp</span></h1>'
let str = itheima.htmlEscape(htmlStr)
console.log(str)
// result:
// &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp&lt;/span&gt;&lt;/h1&gt;

还原html中的特殊字符

let str = '&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp&lt;/span&gt;&lt;/h1&gt;'
let htmlStr = itheima.htmlUnEscape(str)
console.log(htmlStr)
//result:
// <h1 title="abc">这是h1标签<span>123&nbsp</span></h1>

开源协议

ISC