1.0.0 • Published 1 year ago

dqf-base v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

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);
// &lt;h1 style=&quot;color: #F00;&quot;&rt;标题&lt;/h1&rt;

还原 HTML 中的特殊字符

// 待还原的字符串
const str = "&lt;h1 style=&quot;color: #F00;&quot;&rt;标题&lt;/h1&rt;";
const html = ITHEIMA.htmlUnEscape(str);
console.log(html);
// <h1 style="color: #F00;">标题</h1>

开源协议

ISC