lpy_testpkg
v1.0.0
Published
提供格式化时间,转译html字符的功能
Downloads
4
Maintainers
Readme
安装
npm install lpy_testpkg
导入
const utils = require('lpy_testpkg')
格式化时间
// 调用 dateFormat 对时间进行格式化
const dt = m.dateFormat(new Date())
console.log(dt)
// 输出:2021-12-23 17:09:11
转译 html 中特殊字符
// 待转换的 html 字符串
const htmlStr = '<h1 class="red">你好!<span>123 </span></h1>'
const newStr = m.htmlEscape(htmlStr)
console.log(newStr)
// 输出: <h1 class="red">你好!<span>123&nbsp;</span></h1>
还原 html 中的特殊字符
// 待还原的字符
const str =
'<h1 class="red">你好!<span>123&nbsp;</span></h1>'
const htmlStr = m.htmlUnEscape(str)
console.log(htmlStr)
// 输出:<h1 class="red">你好!<span>123 </span></h1>
开源协议
ISC