1.0.0 • Published 2 years ago

itheima-yi v1.0.0

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

安装

npm install itheima-yi

导入

const yi=require('itheima-yi');

格式化时间

const dtstr=yi.dateformat(new Date());
console.log(dtstr);
// 结果:2022-07-31 13:27:33

转义html中的特殊字符

const htmlstr='<h1 title="abc">这是h1<span>123&nbsp;</span></h1>';
const str=yi.htmlescape(htmlstr);
console.log(str);
// 结果:&lt;h1 title=&quot;abc&quot;&gt;这是h1&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原html中的特殊字符

// 还原
const str2=yi.htmlunescape(htmlstr);
console.log(str2);
// 结果:<h1 title="abc">这是h1<span>123&nbsp;</span></h1>

开源协议

ISC