1.0.0 • Published 5 months ago

itheima-tools-fzp v1.0.0

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

安装

npm install itheima-tools-fzp

导入

const itheima = require("itheima-tools-fzp")

格式化时间

// 调用 dataFormat 对时间进行格式化
const dtStr = itheima.dataFormat(new Date())
// 结果 2023-12-00 17:41:39
console.log(dtStr);

转义 HTML 中特殊字符

// 带转换的 HTML 字符串
const htmlStr = '<h1>测试转义HTML是否成功<span>測試用例</span></h1>'
// 调用 htmlEscape 方法进行转换
const str = itheima.htmlEscape(htmlStr)
// 结果 &lt;h1&gt;测试转义HTML是否成功&lt;span&gt;測試用例&lt;/span&gt;&lt;/h1&gt;
console.log(str);

还原 HTML 中的特殊字符

// 带还原的 HTML 字符串
const newStr = itheima.htmlUnEscape(str)
// 结果 <h1>测试转义HTML是否成功<span>測試用例</span></h1>
console.log(newStr);

开源协议

ISC

1.0.0

5 months ago