1.0.0 • Published 3 years ago
itheima-lzrr v1.0.0
安装
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)
// 转换结果 <div>你<h1>滚</h1><h4>吧</h4></div>
console.log(str)
// 待还原的 HTML 字符串
const str2 = itheima.unHtmlEscape(str)
// 结果 <h1 style="fontSize:30px">哈哈哈哈哈<span>耦合</span></h1>
console.log(str2)
开源协议 滚吧。
1.0.0
3 years ago