2.0.0 • Published 2 years ago
itheima-tools-zgf v2.0.0
安装
npm install itheima_tools_zgf
导入模块
// 导入模块
const itheima_zgf = require('./index');
格式化时间
// 格式化时间:
console.log(itheima_zgf.dateformat());
// 输出结果:2022-07-16 - 11:48:26
转义html特殊字符
//准备字符串
const htmlstr = '<h1 title="abc">我是h1标签<span>&&123我是span</span></h1>';
// 转义html特殊字符
console.log(itheima_zgf.htmlescape(htmlstr));
// 输出结果:$lth1 title="abc"$gt我是h1标签$ltspan$gt&&123我是span$lt/span$gt$lt/h1$gt
还原html特殊字符
//准备字符串
const str = '<h1 title="abc">我是h1标签<span>&&123我是span</span></h1>';
// 还原html特殊字符
console.log(itheima_zgf.htmlUnescape(str));
// 输出结果:<h1 title="abc">我是h1标签<span>&&123我是span</span></h1>
开源协议
ISC