1.0.0 • Published 2 years ago

itheima-tools-lkj v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

npm install itheima-tools-lkj

导入

const itheima = require("./itheima-tools-lkj")

格式化时间

// 调用dateFormat 对时间进行格式化
const dtStr = itheima.dateFormat(new Date())
// 结果 2022-02-05 11:31:17
console.log(dtStr)

转义 HTML 中特殊的字符

// 待转义的 HTML 字符串
const htmlStr = "<p style='blue: red;'>你好! &copy</p>"
// 调用 htmlEscape 方法进行转义
const str = itheima.htmlEscape(htmlStr)
// 输出的结果 &lt;p style='blue: red;'&gt;你好! &amp;copy&lt;/p&gt;
console.log(str)
// 待还原的 HTML 字符串
const str2 = itheima.htmlEscape(str)
// 输出的结果 <p style='blue: red;'>你好! &copy</p>;
console.log(str2)

开源协议

ISC