1.0.0 • Published 2 years ago

itheima-tools-wjwjwj v1.0.0

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

安装

npm install itheima-tools-wj

导入

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

1.格式化时间

const dtStr=itheima.dateFormat(new Date())
//结果是2023-05-08  16:21:26
console.log(dtStr)

2.转义HTML中的特殊字符

//待转换的HTML字符串
const htmlStr='<h1 class="one">123<span>456&nbsp;</span></h1>'
//调用htmlEscope方法进行转换
const str = itheima.htmlEscope(htmlStr)
//结果是&lt;h1 class=&quot;one&quot;&gt;123&lt;span&gt;456&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str)

3.还原HTML中的特殊字符

//待还原的HTML字符串
const str2=itheima.htmlUnEscope(str)
//结果是<h1 class="one">123<span>456&nbsp;</span></h1>
console.log(str2)

开源协议

ISC