lizhixiangstart-itheima-tools
v1.0.0
Published
提供了格式化时间,HTML Escape的功能
Downloads
1
Maintainers
Readme
安装
npm install itheima-tools
导入
const itheima = require('itheima-tools')
格式化
//调用 dateFormat对时间进行格式化
const dt = new Date();
// 结果 2023-05-05 00:10:57
console.log(dt)
转义HTML中特殊字符
// 定义待转换的字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>';
let escapedHtml = itheima.htmlEscape(htmlStr);
console.log(escapedHtml);
let unescapeHtml = itheima.htmlUnEscape(escapedHtml);
console.log(unescapeHtml);
还原HTML中特殊字符
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>';
let escapedHtml = itheima.htmlEscape(htmlStr);
console.log(escapedHtml);
let unescapeHtml = itheima.htmlUnEscape(escapedHtml);
console.log(unescapeHtml);
开源协议
ISC