mydemo_kdl
v1.0.0
Published
这是我的自定义的包,包含格式化时间等功能
Downloads
5
Readme
1.安装方式
npm install MyDemo_kdl
2.导入方式
const myDemo=require('MyDemo')
3.格式化时间方法
function formatDate() {
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 "<";
case ">":
return ">";
case "&":
return "&";
case '"':
return """;
}
})
}
5.html还原方法
function htmlUnEscape(Str){
return Str.replace(/<|>|"|&/g,(match)=>{
switch(match){
case "<":
return "<";
case ">":
return ">";
case """:
return '"';
case "&":
return "&";
}
})
6.开源协议
ISC