1.0.0 • Published 2 years ago
ybhdsgtools v1.0.0
安装
npm install mytools
导入
const mytools =require("mytools)
格式化时间
// 调用 dateFormat 对时间进行格式化
const time = mytools.dataFormat(new Date());
// 结果 2022-01-16 17:20:58
console.log(time);
转义 HTML 中的特殊字符
var str = '<h1>123&456&"123"</h1>';
// 调用 htmlEscape 转义特殊字符
const escape = mytools.htmlScape(str);
// 结果 <h1>123&456&"123"</h1>
console.log(escape);
还原 HTML 中的特殊字符
// 调用 htmlUnEscape 还原特殊字符
const escape2 = mytools.htmlUnEscape(str);
// 结果<h1>123&456&"123"</h1>
console.log(escape2);
开源协议
ISC
1.0.0
2 years ago