1.0.0 • Published 3 years ago

xq_npm v1.0.0

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

//安装方式、导入方式、格式化时间、转义 HTML 中的特殊字符、还原 HTML 中的特殊字符、开源协议

安装

npm install xu_npm 

导入

const xq = require('xq_npm')

格式化时间

//调用 dateFormat 对时间格式化
const dtStr = xq.dateFormat(new Date())
//结果 2022-05-01 22:26:50
console.log(dtStr)

转义HTML中的特殊字符

//调用 htmlEscape
const h1 = xq.htmlEscape('<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>')
//结果 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(h1)

还原 HTML 中的特殊字符

//调用 htmlUnEscape
const h2 = xq.htmlUnEscape('<&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;')
//结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(h2)

开源协议

ISC