1.0.1 • Published 2 years ago

dome1dome1domeskt v1.0.1

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

安装

npm install dome1dome1domeskt

导入

const yuan = require('./dome1dome1domeskt')

格式化时间

const date = new Date()
// 调用dateFormat对时间进行格式化
console.log(yuan.dateFormat(date))

转义html中的特殊字符

const str = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
// 调用htmlEscape对特殊字符进行转义
const newStr = yuan.htmlEscape(str)
// 转换的结果为 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(newStr)

还原html总的特殊字符

const str = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
const newStr = yuan.htmlEscape(str)
console.log(newStr)
// 调用htmlUnEscape对特殊字符进行还原
console.log(yuan.htmlUnEscape(newStr))

开源协议

ISC