JSPM

itheima-tools-cuicui

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

    CUICUI自制的,提供了格式化时间,HTMLEscape的功能

    Package Exports

    • itheima-tools-cuicui
    • itheima-tools-cuicui/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-cuicui) 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-cuicui

    导入

    const itheima = require('itheima-tools-cuicui')

    格式化时间

    //调用 dataFormat 对时间进行格式化
    const dateStr = itheima.dateFormat(new Date())
    //结果 2023-01-00 18:52:28
    console.log(dateStr);

    转义html中的特殊字符

    //定义待转换的字符串
    let str = '<h1>hello</h1>'
    //调用 htmlEscape 对字符串进行转换
    str = itheima.htmlEscape(str);
    //结果 &lth1&gthello&lt/h1&gt
    console.log(str);

    还原html中的特殊字符

    //定义待还原的字符串
    let htmlstr1 = '&lth1&gthello&lt/h1&gt';
    //调用 htmlUnEscape 对字符串进行还原
    htmlstr1 = itheima.htmlUnEscape(htmlstr1);
    //结果 <h1>hello</h1>
    console.log(htmlstr1);

    开源协议

    ISC