1.0.1 • Published 2 years ago
itheima-tools-sc v1.0.1
安装
npm install itheima-tools-sc
导入
const itheima = require('itheima-tools-sc)
格式化时间的功能
//使用 dateFormat 进行时间的格式化
const dateStr = itheima.dateFormat(new Date());
// 结果:2022-05-05 21:47:52
console.log(dateStr);
将html字符传换义
//待转换的html字符
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>';
// 利用htmlEscape 进行字符的转换
const str = itheima.htmlEscape(htmlStr);
// 结果: <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(str);
将转义后的html字符进行还原
//利用htmlUnEscape 进行还原
const str2 = itheima.htmlUnEscape(str);
// 结果:<h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(str2);
开源协议
ISC