1.0.1 • Published 1 year ago
txx-tools v1.0.1
安装
npm i txx-tools
导入
const itheima = require('txx-tools')
格式化时间
// 调用dataFormat对时间进行格式化
const dtStr = itheima.dataFormat(new Date());
// 结果 2022-12-23 10:06:26
console.log(daStr);
转义HTML中特殊字符
// 待转义HTML字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123R </span></h1>';
// 调用htmlEscape方法
const str = itheima.htmlEscape(htmlStr);
// 输出结果
console.log(str);
还原HTML中的特殊字符
// 待转义HTML字符串
const str2 = itheima.htmlUnEscape(str);
// 输出结果
console.log(str2);
开源协议
ISC