1.0.0 • Published 5 years ago

it-lianxi-tools v1.0.0

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

安装

npm install it-lianxi-tools

导入

const it=require('it-lianxi-tools')

格式化时间

//  调用 dateFormat 对时间进行格式化
const dtStr = it.dateFormat(new Date())
console.log(dtStr);
// 结果 xxxx-xx-xx xx:xx:xx

转义HTML中的特殊字符

//待转换的HTML字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>span标签&nbsp;</span></h1>'
//调用HTMLEscape方法进行转换
const str = ithm.htmlEscape(htmlStr);
console.log(str);
// 输出结果 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;span标签&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原HTML中特殊字符

//待转换的HTML字符串--str
const str2 = ithm.htmlUnEscape(str);
console.log(str2);
// 输出结果 <h1 title="abc">这是h1标签<span>span标签&nbsp;</span></h1>

开源协议

ISC

1.0.0

5 years ago