npm install itheima-tools
const itheima = require('itheima-tools')
//调用dataFormat对时间进行格式化
const dt = itheima.dateFormat(new Date())
// 结果 2022-11-18 15:39:40
console.log(dt);
//定义待转换的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字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
//调用htmlUnEscape方法进行还原
const str = itheima.htmlUnEscape(htmlStr)
//还原的结果 <h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(str);
ISC