1.0.0 • Published 2 years ago
itheima-tools-liuting v1.0.0
安装
npm install itheima-tools-liuting
导入
const itheima = require('itheima-tools-liuting')
格式化时间
// 调用dateFormat对时间进行格式化
const dt = itheima.dateFormat(new Date())
// 结果 2022-07-04 18:31:08
console.log(dt)
转义HTML 中的特殊字符
// 待转换的HTML字符串
const htmlStr = '<h1>aaaa</h1>'
// 调用htmlEscape方法进行转换
const newStr = itheima.htmlEscape(htmlStr)
// 转换结果 <h1>aaaa<\h1>
console.log(newStr)
还原HTML 中的特殊字符
// 待还原的HTML字符串
const htmlStr2 = '<h1>aaaa</h1>'
// 调用htmlUnEscape方法进行还原
const newStr2 = itheima.htmlUnEscape(htmlStr2)
// 还原结果 <h1>aaaa</h1>
console.log(newStr2)
开源协议
ISC
1.0.0
2 years ago