1.0.0 • Published 4 years ago

hyf-publish001 v1.0.0

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

1.安装方式

npm install hyf-publish001

2.导入方式

const itheima=require('itheima-tools')

3.格式化时间

// 调用dateFormat对时间进行格式化
const dt = itheima.dataFormat(new Date())
// 结果 2021-01-19 14:19:56
console.log(dt);

4.转义HTML中的特殊字符

// 定义待转化的HTML字符串
const htmlStr = '<h1 style="color:red;">你好!&copy;<sapn>小黄!</sapn></h1>'
// 调用htmlEscape方法进行转换
const str = itheima.htmlEscape(htmlStr)
// 转换结果 &lt;h1 style=&quot;color:red;&quot;&gt;你好!&amp;copy;&lt;sapn&gt;小黄!&lt;/sapn&gt;&lt;/h1&gt;
console.log(str);

5.还原HTML中的特殊字符

// 待还原的html字符串
const rawHTML = itheima.htmlUnEscape(str)
//输出结果 '<h1 style="color:red;">你好!&copy;<sapn>小黄!</sapn></h1>'
console.log(rawHTML);

6.开源协议

ISC

1.0.0

4 years ago