itheima-tools-un

1.0.0 • Public • Published

##安装

 npm i itheima-tools

##导入

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

##格式化时间

const dateStr=itheima.dateFormat(new Date());
console.log(dateStr);
//结果 2022-03-22 16:23:36

##转义HTML中的特殊字符

//定义html字符串
const htmlStr='<h1 title="123">123&nbsp;</h1>'
//调用转移函数
const str = itheimai.htmlEscape(htmlStr);
console.log(str);
//结果
&lt;h1 title=&quot;123&quot;&gt;123&amp;nbsp;&lt;/h1&gt;

##还原HTML代码

//待还原的html字符串
const html=itheima.htmlUnEscape(str);
console.log(html);
//结果 <h1 title="123">123&nbsp;</h1>

##开源协议 ISC

Package Sidebar

Install

npm i itheima-tools-un

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.51 kB

Total Files

5

Last publish

Collaborators

  • haoshuaipeng