1.0.0 • Published 3 years ago

itheima-lzrr v1.0.0

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

安装

nmp install itheima-lzr

导入

const itheima = require('itheima-tool') 

格式化日期

// 调用format 格式化时间
const dtStr = itheima.dateFormat(new Date())
// 结果  2021-01-07 20:48:42
console.log(dtStr)

转义 HTML 中的特殊字符

// 带转换的 HTML 字符串
const htmlStr = `<div>你<h1>滚</h1><h4>吧</h4></div>`
// 调用 htmlEscape 方法进行转换
const str = itheima.htmlEscape(htmlStr)
// 转换结果 &lt;div&gt;你&lt;h1&gt;滚&lt;/h1&gt;&lt;h4&gt;吧&lt;/h4&gt;&lt;/div&gt;
console.log(str)
// 待还原的 HTML 字符串
const str2 = itheima.unHtmlEscape(str)
// 结果 <h1 style="fontSize:30px">哈哈哈哈哈<span>耦合</span></h1>
console.log(str2)

开源协议 滚吧。