1.0.0 • Published 1 year ago
dqf-base v1.0.0
安装
npm install dqf-base
导入
const ITHEIMA = require('itheima-tools-123');
格式化时间
const dStr = ITHEIMA.dateFormat(new Date());
console.log(dStr); // 2022-12-12 12:12:12
转义 HTML 中的特殊字符
// 待转换的 HTML 字符串
const htmlStr = '<h1 style="color: #F00;">标题</h1>';
const newHtmlStr = ITHEIMA.htmlEscape(htmlStr);
console.log(newHtmlStr);
// <h1 style="color: #F00;"&rt;标题</h1&rt;
还原 HTML 中的特殊字符
// 待还原的字符串
const str = "<h1 style="color: #F00;"&rt;标题</h1&rt;";
const html = ITHEIMA.htmlUnEscape(str);
console.log(html);
// <h1 style="color: #F00;">标题</h1>
开源协议
ISC
1.0.0
1 year ago