1.1.0 • Published 3 years ago
itwcytools v1.1.0
安装
npm install wcy-tools
导入
const wcy =require('wcy-tools');
格式化化时间的代码
//调用 dateFormat 对时间进行格式化
const dtStr = wcy.dateFormat(new Date());
//结果返回 2022-04-05 14:06:23
console.log(dtStr);
转义 HTML中的特殊字符
//带转换的 HTML字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span>;<h1>'
//调用htmlEscape()进行转化
const str = wcy.htmlEscape(htmlStr);
// 输出结果 <h1 title="abc">这是h1标签<span>123&nbsp</span>;</h1>
console.log(str);
还原HTML 中的转换字符
//带还原的HTML字符串
const str1 = wcy.htmlUnEscape(str);
//输出结果 <h1 title="abc">这是h1标签<span>123 </span>;</h1>
console.log(str1);
开源协议
ISC
1.1.0
3 years ago