JSPM

itheima-tools-zzw

1.1.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q26919F
    • License ISC

    提供了格式化时间、THMLEScape相关的功能

    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);
    // 结果 :   &lth1 title=&quot擦&quot&gt&ltp&gt怕&lt/p&gt&ltspan&gt帝&lt/span&gt&ltstrong&gt&quot秋夜长&amp&amp&quot&lt/strong&gt&lt/h1&gt

    还原 HTML 标签

    const Uhtml = m1.htmlUnEscape(htStr);
    console.log(Uhtml);
    // 输出 :  <h1 title="擦"><p>怕</p><span>帝</span><strong>"秋夜长&&"</strong></h1>

    开源协议

    ISC