1.0.0 • Published 3 years ago
zxty-tools v1.0.0
安装
npm install zxty-tools
导入
const tools = require('zxty-tools')
格式化时间
// 调用dateFormat 对时间进行格式化
const dtStr = tools.dateFormat(new Date())
转义 HTML 中特殊字符
// 定义待转换的字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
// 转换的结果 &alt;h1 title="abc">这是h1标签&alt;span>123undefinednbsp;&alt;/span>&alt;/h1>
const str = tools.htmlEscape(htmlStr)
还原 HTML 中特殊字符
const htmlStr = tools.htmlUnEscape(str)
开源协议
ISC
1.0.0
3 years ago