Package Exports
- itheima-tools-zzw
- itheima-tools-zzw/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (itheima-tools-zzw) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
安装
npm install itheima-tools-zzw
导入
const itheima = require("itheima-tools-zzw");
格式化时间
// 调用dataFormat()方法
const dtStr = m1.dateFormat(new Date());
// 格式化时间的功能
console.log(dtStr); // 2022-09-27 17:13:30
转换 HTML 中的特殊字符
// 待转换的 html 字符
const htmlStr = `<h1 title="擦"><p>怕</p><span>帝</span><strong>"秋夜长&&"</strong></h1>`;
// 调用 htmlEscape 方法进行转换
const htStr = m1.htmlEscape(htmlStr);
console.log(htStr);
// 结果 : <h1 title="擦"><p>怕</p><span>帝</span><strong>"秋夜长&&"</strong></h1>
还原 HTML 标签
const Uhtml = m1.htmlUnEscape(htStr);
console.log(Uhtml);
// 输出 : <h1 title="擦"><p>怕</p><span>帝</span><strong>"秋夜长&&"</strong></h1>
开源协议
ISC