1.0.0 • Published 2 years ago
my-custom-node-mjy v1.0.0
##安装方式
1.1使用npm安装
npm i my-tools
2.导入方式
const my = require("my-tools")
3.格式化时间
//格式化时间
function dateFormat(){
var date=new Date()
var year=date.getFullYear();
var month=date.getMonth()+1;
var today=date.getDate();
var hour=date.getHours();
var minute=date.getMinutes();
var second=date.getSeconds();
var time=year+"年"+month+"月"+today+"日 "+hour+":"+minute+":"+second;
console.log(time);
}
4转义HTML中的特殊字符
//转义字符
function zhuanHTML(html){
html.replace(/<|>|"|&/g,(i)=>{
switch (i){
case "<":
return <
case ">":
return >
case '"':
return "
case '&':
return &
}
})
}
5还原特殊字符
//还原特殊字符
function huanHTML(html){
return html.replace(/<|>|"|&/g,(i)=>{
switch (i){
case "<":
return "<";
case ">":
return ">";
case '"':
return '"';
case '&':
return "&";
}
})
}
6开源协议
RSC
1.0.0
2 years ago