1.0.0 • Published 1 year ago
xswff-tools v1.0.0
安装
npm install xswff-tools
导入
const xswff = require('xswff-tools')
格式化时间
//调用deteFormat 对时间进行格式化
const newDate= xswff.dateFormat(new Date())
console.log(newDate)
//结果 2022-12-05 00:08:33
转义html中的特殊字符
//带转换的html字符串
const htmlStr='<h1 title="abc">这是h1标签<span>123 </span></h1>'
// 调用htmlEscape方法进行转换
const str= xswff.htmlEscape(htmlStr)
console.log(str)
//结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
还原html中的特殊字符
//使用htmlUnEscape方法进行还原 str为待还原的字符
const str2=xswff.htmlUnEscape(str)
console.log(str2);
//结果 <h1 title="abc">这是h1标签<span>123 </span></h1>
开源协议
ISC
1.0.0
1 year ago