1.0.0 • Published 5 years ago

ithm123-tools v1.0.0

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

安装

npm install ithm123-tools

导入

js

const itheima =require('ithm123-tools')

格式化时间

js

调用  dateFormat对时间进行格式化
const aa = new Date();
var cc = ee.dateFormat(aa); 

console.log(cc)
 // 结果  2021-01-08 10:24:34

转义 html 中的特殊字符

js
//  待转换的字符串
const ht111 = '<h1 title="abc">这是标题<span>13311&nbsp;</span></h1>';

//  调用htmlescape   方法  进行转换
const dp1 = ee.htmlEscape(ht111);

console.log(dp1);
//  转换的结果

&lt;h1 title=&quot;abc&quot;&gt;这是标题&lt;span&gt;13311&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原 html 中的特殊字符

js
//  待还原的字符串
&lt;h1 title=&quot;abc&quot;&gt;这是标题&lt;span&gt;13311&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

//  调用htmlunescape   方法  进行还原
const pl = ee.htmlUnEscape(dp1);


console.log(pl);
//  转换的结果
<h1 title="abc">这是标题<span>13311&nbsp;</span></h1>

开源协议

ISC

1.0.0

5 years ago