1.0.0 • Published 3 years ago
xh-tools v1.0.0
安装
npm install xh-tools
导入
const xhtools = require('xh-tools')
格式化时间
// 调用dataFormat格式化时间
const dtStr = xhTools.dataFormat(new Date())
// 结果 2022-08-19 09:53:27
console.log(dtStr);
转义html 中的特殊字符
// 带转换的html文字
const htmlStr = '<h1 title="abc">这是一个h1标签<span>123 </span></h1>'
// 调用 htmlEscape 方法进行转换
const str = xhTools.htmlEscape(htmlStr)
// 转换的结果 <h1 title="abc">这是一个h1标签<span>123&nbsp</span></h1>
console.log(str);
还原html 中的字符串
// 待还原的 html 字符串
const html = xhTools.htmlunEscape(str)
//输出结果 <h1 title="abc">这是一个h1标签<span>123 </span></h1>
console.log(html);
开源协议
ISC
1.0.0
3 years ago