1.0.0 • Published 2 years ago

itheima-tools-wq v1.0.0

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

安装

npm install itheima-tools-wq

导入

const itheima = require("./itmeima-tools/index")

格式化时间

// 调用格式化时间函数
const dt = itheima.dataFromat(new Date())
console.log(dt);
//输出结果2022-05-04  21:14:53

转义HTML中的特殊字符

// 待转义的字符
const htmlstr = '&nbsp<h1>首页<span>123</span></h1>'
// 调用函数进行转义
const str = itheima.htmlEscape(htmlstr)
console.log(str);
//输出结果&amp;nbsp&lt;h1&gt;首页&lt;span&gt;123&lt;/span&gt;&lt;/h1&gt;

还原HTML中的特殊字符

// 调用函数转义还原字符
const str1 = itheima.htmlUnEscape(str)
console.log(str1);
//输出结果&nbsp<h1>首页<span>123</span></h1>

开源协议

"license": "ISC"