1.0.0 • Published 5 months ago
matt123-tools v1.0.0
安装
npm install matt-tools
导入
const tools=require("matt-tools")
格式化时间
//调用formatTime对时间进行格式化
let time=tools.formatTime(new Date())
//输出结果 2023-12-01 16:09:14
console.log(time)
转义HTML中的特殊字符
//调用htmlEncode对HTML中的特殊字符
let str=tools.htmlEncode('<h1 style="color:#f12">哈哈哈 </h1>')
//输出结果 <h1 style="color:#f12">哈哈哈&nbsp;</h1>
console.log(str)
还原HTML中特殊字符
//调用htmlEncode对HTML中的特殊字符
let str="<h1 style="color:#f12">哈哈哈&nbsp;</h1>"
//输出结果 <h1 style="color:#f12">哈哈哈 </h1>
console.log(tools.htmlDecode(str))
开源协议
ISC
1.0.0
5 months ago