1.0.0 • Published 2 years ago

zzheima-hyj v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装方式

npm install hyj

导入方式

const hyj = require('hyj')

格式化时间

// 调用dataFormat方法,对时间格式化
const dataStr = hyj.dataFormat(new Date())
// 结果2022-09-22  19:24:30
console.log(dataStr);

转义 HTML 中的特殊字符

// 调用htmlEscape方法,转义 HTML 中的特殊字符
const htmlStr = hyj.htmlEscape('<h1 style="color">转换html标签的函数</h1>');
// 结果 &it;h1 style=&quot;color&quot;&gt;转换html标签的函数&it;/h1&gt;
console.log(htmlStr);

还原 HTML 中的特殊字符

const htmlStr = hyj.htmlEscape('<h1 style="color">转换html标签的函数</h1>');
// 调用htmlUnEscape方法,还原 HTML 中的特殊字符
const html = hyj.htmlUnEscape(htmlStr);
// 结果 <h1 style="color">转换html标签的函数</h1>
console.log(html);

开源协议

ISC