1.0.0 • Published 2 years ago
hongbing5 v1.0.0
安装
npm install hongbao
导入
const hongbao = require('hongbing')
格式化时间
//调用 dateFormat 对时间进行格式化
const dt = hongbao.dateFormat(new Date())
//结果 2022-05-13 18:54:56
console.log(dt)
转义 HTML 中的特殊字符
//带转换的 HTML 字符串
const htmlStr = '<p title="abc"> <i>SMM</i>永远 的神 </p>'
//调用 htmlEscape 方法进行转换
let str = hongbao.htmlEscape(htmlStr)
//转换的结果 <p title="abc"> <i>SMM</i>永远&nbsp;的神 </p>
console.log(str)
还原 HTML 中的特殊字符
//带还原的的 HTML 字符串
const htmlStr1 = '<p title="abc"> <i>SMM</i>永远&nbsp;的神 </p>';
//调用 htmlUnEscape 方法进行转换
let str1 = hongbao.htmlUnEscape(htmlStr1)
//转换的结果'<p title="abc"> <i>SMM</i>永远 的神 </p>';
console.log(str1)
开源协议
ISC
1.0.0
2 years ago