1.0.0 • Published 2 years ago
ithema-toolsxwg v1.0.0
安装
npm install ithema-toolsxwg
导入
const ithema=require('ithema-toolsxwg')
格式化时间
const dt=ithema.dateFormat(new Date())//调用dateFormat()对事件进行格式化
console.log(dt)//结果2022-10-25 14:53:24
转义HTML中的特殊字符
//待转化的HTML字符
const htmlStr='<h1>这是h1<span>哈哈哈&</span></h1>'
//调用htmlEscape方法进行转化
const newStr=ithema.htmlEscape(htmlStr)
//转化结果为<h1>这是h1<span>哈哈哈&</span></h1>
console.log(newStr)
还原HTML中的特殊字符
//待还原的HTML字符串
const newStr2=ithema.htmlUnEscape(newStr)
//输出结果<h1>这是h1<span>哈哈哈&</span></h1>
console.log(newStr2)
开源协议
ISC
1.0.0
2 years ago