1.0.0 • Published 1 year ago
itheima-tools-woaiye v1.0.0
安装
npm install itheima-tools
导入
const m=require("itheima-tools")
格式化时间
// 调用 dataformat 对时间进行格式化
const newdt=m.dataformat(dt);
// 结果 2022-12-02 13:23:45
console.log(newdt);
转义html中的特殊字符
// 待转换的html字符串
const htmlstr='<h1>哈哈<span>123 </span></h1>'
// 调用 htmlescape 对字符串进行转换
const res=m.htmlescape(htmlstr);
//结果 <h1>哈哈<span>123&nbsp;</span></h1>
转义html中的特殊字符
// 待还原的html字符串
const htmlstr='<h1>哈哈<span>123&nbsp;</span></h1>'
// 调用 htmlescape 对字符串进行还原
const res=m.htmlunescape(htmlstr);
//结果 <h1>哈哈<span>123 </span></h1>
开源协议
ISC
1.0.0
1 year ago