1.0.1 • Published 2 years ago
itheima-zzt-tools v1.0.1
安装
npm install itheima-zzt-tools
导入
const itzzt = require('itheima-zzt-tools')
格式化时间
// 调用 dateFormat 对时间进行格式化
const dtStr = itzzt.dateFormat(new Date())
// 格式化结果如:2023-03-14 15:28:57
console.log(dtStr);
转义 HTML 中的特殊字符
// 待转换的 HTML 字符串
const htmlStr = '<h1>这是标题</h1>'
// 调用 htmlEscape 方法进行转换
const str1 = itzzt.htmlEscape(htmlStr)
// 转换结果如:<h1>这是标题</h1>
console.log(str1);
还原 HTML 中的特殊字符
// 待还原的 HTML 字符串
const str2 = itzzt.htmlUnEscape(str1)
// 还原结果如:<h1>这是标题</h1>
console.log(str2);
开源协议
ISC
1.0.1
2 years ago