1.0.0 • Published 2 years ago

pliulr v1.0.0

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

安装

npm install pliulr

导入

const pliulr = require('pliulr')

格式化时间

// 调用dateFormat对时间进行个格式化
const d = m1.dateFormat(new Date())
console.log(d);

转义html的特殊字符

// 带转换的html字符串
const ht = "<h1 title='abc'>这是h1标签<span>123&nbsp;</span></h1>"
// 调用方法进行转换
const d2 = m1.htmlEscape(ht)
// 输出转换的结果  &lt;h1 title='abc'&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(d2);

还原html中的特殊字符

// 带还原的html的字符串
const gg = "&lt;h1 title='abc'&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;"
// 调用方法进行转换
const s = m1.htmlUnEscape(gg)
// 打印输出结果
console.log(s);

开源协议

ISC