1.0.0 • Published 2 years ago
htxx_tools v1.0.0
安装
npm install ytxx_sools
导入
const itheima = require("ytxx_sools");
格式化时间
//调用dateFormat 对时间进行格式化
const dtStr_1 = ytxx_tools.dateFormat(new Date()); //接收格式化后的时间
console.log(`ytxx_tools提供的时间:${dtStr_1}`); //打印时间格式为2022-06-12 10:32:33
转义 html,中的特殊字符
//待转换的html字符
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbst;</span></h1>'; //声明变量接收html标签
//调用htmlEscape方法进行转换
const str = ytxx_tools.htmlEscape(htmlStr); //传入需要转义的html标签并且接收返回处理的结果
//转换的结果:<h1 title="abc">这是h1标签<span>123&nbst;</span></h1>
console.log(`转义过的字符${str}`); //输出到命令窗口
还原 hthl 中的特殊字符
//待还原的html字符
const str_1 = ytxx_tools.htmlUnEscape(str); //传入被转义过的字符进行处理,然后接收结果
//还原html字符的结果:<h1 title="abc">这是h1标签<span>123&nbst;</span></h1>
console.log(`还原转义过的字符${str_1}\n`); //输出到命令窗口
开源协议
ISC
1.0.0
2 years ago