1.0.0 • Published 2 years ago
itheima-trtool v1.0.0
安装
··· npm install itheima-trtool ···
导入
···js const itheima = require("itheima-trtool") ···
格式化时间
··· const newDate = new Date(); //调用format 对时间进行格式式化 const nowdate = itheima.format(newDate) //输出结果为 2022-07-05 08:31:31 console.log(nowdate); ···
转义HTML中的特殊字符串
··· //定义一个字符串 const str = '这是h1标签 123 '; //使用HTMLEscape对特殊字符串进行处理 const newStr = itheima.HTMLEscape(str); //输出结果为 <h1 title="abc">这是h1标签 <sapn>123 </sapn></h1> console.log(newStr); ···
还原HTML中的特殊字符串
··· //使用HTMLUnEscape还原HTML中的特殊字符串 const str2 = itheima.HTMLUnEscape(newStr); //输出结果为 这是h1标签 123 console.log(str2); ···
开源协议
ISC
1.0.0
2 years ago