1.0.0 • Published 3 years ago

lxy-dateformat-tool v1.0.0

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

安装

npm install lxy-dateformat-tool

导入

const lxy=require('lxy-dateformat-tool')

格式化时间

// 调用dateFormat对时间进行格式化
const dtStr = lxy.dateFormat(new Date())
console.log(dtStr)
// 输出结果 2022-02-19 13:42:21

转义 HTML中的特殊字符

// 待转换的 HTML字符串
const htmlStr = '<h1>这是h1标签 &nbsp</h1>'
// 调用htmlEscape方法进行转换
const str = lxy.htmlEscape(htmlStr)
console.log(str)
// 输出结果 &lt;h1&gt;这是h1标签 &nbsp&lt;/h1&gt;

还原 HTML中的特殊字符

// 调用htmlUnEscape方法进行还原
const str2 = lxy.htmlUnEscape(str)
console.log(str2)
// 输出结果<h1>这是h1标签 &nbsp</h1>

开源协议

ISC