mydemo_ljy

1.0.0 • Public • Published

1.安装方式

npm install MyDemo_ljy

2.导入方式

const myDemo = require('MyDemo')

3.格式化时间方法

    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
    
}  

4.html转义方法

function htmlEscape(htmlStr) {
    return htmlStr.replace(/<|>|"&/g,(match)=>{
        switch(match){
            case '<':
                return "&lt;";
            case '>':
                return "&gt;";
            case '"':
                return "&quot;";
            case '&':
                return "&amp;";

        }
    })
}

5.还原方法

function htmlUnEscape(htmlStr) {
    return htmlStr.replace(/&lt;|&gt;|&quot;|&amp;/g,(match)=>{
        switch(match){
            case '&lt;':
                return "<";
            case '&gt;':
                return ">";
            case '&quot;':
                return '"';
            case '&amp;':
                return "&";

        }
    })
}

6.开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i mydemo_ljy

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

3.35 kB

Total Files

5

Last publish

Collaborators

  • ljycfg