cjl_npm_tools
Version:
提供了关于时间,日期方面的方法,还有像深度拷贝,封装的百度翻译,16进制颜色转换等
36 lines (34 loc) • 822 B
JavaScript
//定义转义HTML字符的函数
function htmlEscape(html){
return html.replace(/<|>|"|&/g,(res)=>{
switch (res) {
case '<':
return '<'
case '>':
return '>'
case '&':
return '&'
case '"':
return '"'
}
})
}
//定义还原HTML字符的函数
function UnhtmlEscape(html){
return html.replace(/<|>|&|"/g,(res)=>{
switch (res) {
case '<':
return '<'
case '>':
return '>'
case '&':
return '&;'
case '"':
return '"'
}
})
}
module.exports={
htmlEscape,
UnhtmlEscape
}