itheima-tools-fzp

1.0.0 • Public • Published

安装

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

Package Sidebar

Install

npm i itheima-tools-fzp

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.7 kB

Total Files

5

Last publish

Collaborators

  • terraria9747