1.0.1 • Published 2 years ago
itheima-toolssss-apple v1.0.1
导入
const itheima = require('itheima-toolssss-apple')
格式化时间
//调用dateFormat 对时间进行格式化
const dtStr = itheima.dateFormat(new Date())
//结果 2022-08-04-20-57-47
consloe.log(daStr)
定义转义 HTML 字符的函数
//带转化的 HTML 字符串
const htmlStr = '<h1 title="123">qwe<span>1111</span></h1>'
// 调用 htmlEscape 方法进行转化
const Str = itheima.htmlEscape(htmlStr)
//转化的结果为 <h1 title="123">qwe<span>1111</span></h1>
consloe.log(Str)
定义还原转义 HTML 字符的函数
//带需要还原的 HTML 字符串
const text = '<h1 title="123">qwe<span>1111</span></h1>'
// console.log(str);
// 调用 htmlUnEscape 方法进行转化
const str = itheima.htmlUnEscape(text)
//转化的结果为 <h1 title="123">qwe<span>1111</span></h1>
console.log(str);
开源协议
ISC
1.0.1
2 years ago