1.0.0 • Published 2 years ago
itheima-tools-ray v1.0.0
安装方式
npm i itheima-tools-ray
导入方式
cosnt it = require('itheima-tools-ray');
格式化时间
// 调用 dateFormat 对时间进行格式化
const dtStr = it.dateFormate(new Date())
// 结果 [当前时间][yyyy-mm-dd hh:mm:ss]
console.log(dtStr);
转义 html 中的特殊字符
// 待转换的 HTML 字符串
const htmlStr = '<h1 title="h1_txt">这是h1标签<span>这是span标签</span></h1>'
// 调用 htmlEscape 方法进行转换
const str = it.htmlEscape(htmlStr)
// 转换的结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(str)
还原 html 中的特殊字符
// 待还原的 HTML 字符串
const htmlStr = it.htmlUnEscape(str)
// 输出的结果 <h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(htmlStr)
开源协议
ISC
1.0.0
2 years ago