1.0.0 • Published 3 years ago

itiheima-tools-zb v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

安装方式

    node install itheima-tools-zb

导入方式

    const itheima = require('itheima-tools-zb');

格式化时间

    //代码演示
    const date = new Date();
    console.log(itheima.dateFormat(date));
    //输出结果  2022-11-08 14:12:43

转移HTML特殊字符

    //代码演示
    const htmlStr = '<h1 href="&">这是一个HTML转义字符的方法</h1>';
    console.log(itheima.HTMLEscape(htmlStr));
    //输出结果  &lt;h1 href=&quot;&amp;&quot;&gt;这是一个HTML转义字符的方法&lt;/h1&gt;

还原HTML转移字符

    //代码演示
    const htmlStr = '<h1 href="&">这是一个还原HTML转义字符的方法</h1>';
    const str = itheima.HTMLEscape(htmlStr);
    console.log(itheima.HTMLUnEscape(str));
    //输出结果  <h1 href="&">这是一个还原HTML转义字符的方法</h1>

开源协议

ISC