1.1.0 • Published 3 years ago

xxgak-myitheima-tools v1.1.0

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

安装

npm install xxgak-myitheima-tools

导入

const heima = require('xxgak-myitheima-tools')

格式化时间

//调用 dateFormat 对时间进行格式化
const str = itheima.dateFormat(new Date())
//结果 2021-9-4 19:26:15
console.log(str)

转义 HTML 中的特殊字符

//待转换的 HTML 字符串
const htmlStr = '<h1 title="abc">你是我的眼</h1>'
//调用 htmlEscape
const newStr = itheima.htmlEscape(htmlStr)
//转换的结果 &lt;h1 title=&quot;abc&quot;&gt;你是我的眼&lt;/h1&gt;
console.log(newStr)

还原 HTML 中的特殊字符

//待还原的 HTML 字符串
const newstr1 = itheima.htmlUnEscape(str1)
//还原结果 <h1 title="abc">你是我的眼</h1>
console.log(newstr1)

开源协议

ISC