1.0.1 • Published 8 months ago
dispose-date-html v1.0.1
安装
npm install dispose-date-html
导入
const disposeDateHtml = require('dispose-date-html')
使用时间格式化
// 调用 formatDate 函数,格式化时间
let tm = tool.formatDate(new Date())
// 格式化时间的结果
console.log('[ tm ] >', tm) // 2023-09-14 11-16-03
转义 html 特殊字符
// 需要转义 html 特殊字符
let htmlStr='<h1 title="abc">这是h1标签<span>123 </span></h1>'
// 调用 htmlEscape 函数,转义 html 特殊字符
let str = tool.htmlEscape(htmlStr)
// 转义 html 特殊字符结果
console.log('[ str ] >', str) // <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
还原 html 特殊字符
// 调用 htmlUnEscape 函数,还原 html 转义符
let str2 = tool.htmlUnEscape(htmlStr)
// 还原 html 特殊字符
console.log('[ str2 ] >', str2) // <h1 title="abc">这是h1标签<span>123 </span></h1>
开源协议
ISC
1.0.1
8 months ago