yezi-tools
v1.0.0
Published
提供了格式化时间,HTMLEscape相关的功能
Readme
安装
npm install yezi-tools
导入
const yezi = require('yezi-tools')
格式化时间
// 调用 dateFormat 对时间进行格式化
console.log(yezi.dateFormat(new Date()))
// 结果: 2025-07-01 10:13:22转义 HTML 中的特殊字符
// 带转换的 HTML 字符串
let str = '<h1 title="标题">标题 </h1>'
// 调用 htmlEscape 方法进行转换
const result = yezi.htmlEscape(str)
// 转换的结果: <h1 title="标题">标题&nbsp;</h1>
console.log(result)还原 HTML 中的特殊字符
// 待还原的 HTML字符串
console.log(yezi.htmlUnEscape(result))
// 输出的结果: <h1 title="标题">标题 </h1>