1.0.1 • Published 2 years ago
ithema-xywtools v1.0.1
安装
npm install ithema-xywtools
导入
cosnt xywtools=require('ithema-xywtools')
格式化时间
// 调用dateFormat格式化时间的功能
const dtStr = xywtools.dateFormat(new Date())
// 结果 2022-08-06 19:01:50
console.log(dtStr);
转义HTML特殊字符串
待转换的html字符串
const htmlStr = '<h1 title="abc>这是H1标签<span>123 </span></h1>'
// 调用htmlEscape方法转换
const str = xywtools.htmlEscape(htmlStr)
// 结果 <h1 title="abc>这是H1标签<span>123 </span></h1>
console.log(str);
还原HTML特殊字符串
// 待还原的html字符串
const str2 = xywtools.htmlUnEscape(str)
// 结果 <h1 title="abc>这是H1标签<span>123 </span></h1>
console.log(str2);
开源协议
ISC