1.0.0 • Published 2 years ago
whhh-utils v1.0.0
安装
npm install whhh-utils
导入
const whhh = require("whhh-utils")
格式化时间
// 调用 dateFormat 对时间进行格式化
const dateStr = whhh.dateFormat(dt)
// dateStr = 2022-01-05 18:44:17
console.log("dateStr = " + dateStr)
转义html字符
// 待转换的字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
// 调用 htmlEscape 方法进行转换
const newHtml = whhh.htmlEscape(htmlStr)
// <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(newHtml)
还原 html 字符
// 待还原的 html 字符串
const newHtmlStr = whhh.htmlUnEscape(newHtml)
// <h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(newHtmlStr)
开源协议
ISC
1.0.0
2 years ago