1.0.0 • Published 5 years ago

itheimaaabb-tools v1.0.0

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

安装方式

npm install itheimaaabb-tools

导入方式

const itheima = require('itheimaaabb-tools')

格式化时间

// 调用dataFormat 对时间进行格式化
const dt1 = itheima.dateFormat(new Date())
// 结果2020-08-04 20:47:51
console.log(dt1);

转义html格式文件

// 待转换的 HTML 字符串
const html = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
// 调用htmlEscape函数对HTML字符串进行转义
const str = itheima.htmlEscape(html)
// 输出结果为&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str);

还原 HTML 中的特殊字符

// 调用htmlUnEscape方法对字符串进行转义
const newStr = itheima.htmlUnEscape(str)
// 输出结果为<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(newStr);

开源协议

ISC

1.0.0

5 years ago