chenxiaohe
v1.0.0
Published
<!-- 这是包的说明文档 -->
Downloads
2
Readme
安装方式
npm install my-tools
导入方式
var mytools=require('myTools')
转义时间
function dateFormat(date) {
var n = date.getFullYear()
var y = date.getMonth() + 1
var r = date.getDate()
var h = yghs(date.getHours())
var m = yghs(date.getMinutes())
var s = yghs(date.getSeconds())
return `${n}-${y}-${r} ${h}:${m}:${s}`
}
转义特殊字符
function htmlEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,function(match){
switch(match){
case'<':
return '<'
case'>':
return '>'
case'"':
return '"'
case'&':
return '&'
}
})
}
还原
function htmlEscap(htmlSt){
return htmlSt.replace(/<|>|"|&/g,function(mat){
switch(mat){
case'<':
return '<'
case'>':
return '>'
case'"':
return '"'
case'&':
return '&'
}
})
}
开源
ISC