1.0.0 • Published 3 years ago
itheima-tools-yly v1.0.0
npm install itheima-tools-yly导入
const itheima = require('itheima-tools-yly')格式化时间
// 调用dataFormat对时间进行格式化
const dt = index.dataFormat(new Date());
console.log(dt);转义 HTML 中的特殊字符
// 待转换的HTML字符串
const htmlStr = '<h1>这是一个"待转义"的HTML字符串&nbps;</h1>';
// 调用htmlEscape方法进行转换
const str = itheima.htmlEscape(htmlStr);
// 转换的结果 <h1>这是一个"待转义"的HTML字符串&nbps;</h1>
console.log(str);还原 HTML 中的特殊字符
// 待还原的HTML字符串
const str2 = index.htmlUnEscape(str));
// 输出的结果 <h1>这是一个"待转义"的HTML字符串&nbps;</h1>
console.log(str);开源协议
ISC
1.0.0
3 years ago