mydemo_lyt
v1.0.0
Published
这是我的自定义的包,包含格式化等功能
Downloads
2
Readme
1.安装方式
npm install MyDemo_lyt
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 htmlUnEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g, (match)=>{
switch(match){
case "<":
return "<";
case ">":
return ">";
case "&":
return "&";
case '"':
return '"';
}
})
}
5.
function htmlEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,(match)=>{
switch(match){
case "<":
return "<";
case ">":
return ">";
case "&":
return "&";
case '"':
return """;
}
})
}
6.开源协议
ISC