itheima-tools-first
v1.0.0
Published
提供了快捷格式化时间、HTMLEscape相关的功能
Readme
##安装
npm install itheima-tools-first##导入
const itheima = require('itheima-tools-first')##格式化时间
//调用dateformat格式化时间并输出(结果:2022-09-18 11:42:06)
console.log(dt.getFormatDate(new Date()));##转义HTML中的特殊字符
//待转换的HTML字符串
const htmlStr = '<h3 style="display: none">首页</h3> <span>天神</span>';
//调用htmlEscape方法进行转换
const str1 = dt.htmlEscape(htmlStr);
//转换的结果(<h3 style="display: none">首页</h3>&nbsp<span>天神</span>)
console.log(str1);##还原HTML中的特殊字符
//调用htmlUnEscape方法进行转换
const str2 = dt.htmlUnEscape(str1);
//转换的结果(<h3 style="display: none">首页</h3> <span>天神</span>)
console.log(str2);##开源协议 ISC
