1.0.0 • Published 11 months ago

lizhixiangstart-itheima-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

安装

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&nbsp;</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&nbsp;</span></h1>';
let escapedHtml = itheima.htmlEscape(htmlStr);
console.log(escapedHtml);
let unescapeHtml = itheima.htmlUnEscape(escapedHtml);
console.log(unescapeHtml);

开源协议

ISC

1.0.0

11 months ago