1.0.0 • Published 2 years ago
itheima-tools-abcd v1.0.0
安装
npm install itheima-tools
导入
const itheima = require('./itheima-tools')
格式化时间
//调用dateFormat方法格式化日期
const dt = itheima.dateFormat(new Date())
console.log(dt);
//结果 2022-07-13 15-56-07
转义HTML中的特殊字符
//调用htmlEscape方法对字符串进行转换
const str = itheima.htmlEscape('<h1 style="color: red">这是一个标题<span>&小明</span></h1>')
console.log(str);
//转换结果 <h1 style="color: red">这是一个标题<span>&小明</span></h1>
还原HTML中的特殊字符
//调用htmlUnEscape方法对字符串进行还原
const rawHtml = itheima.htmlUnEscape(str)
console.log(rawHtml);
//转化结果 <h1 style="color: red">这是一个标题<span>&小明</span></h1>
开源协议
ISC
1.0.0
2 years ago