1.0.0 • Published 2 years ago

itheima-tools-first v1.0.0

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

##安装

npm install itheima-tools-first

##导入

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

##格式化时间

//调用dateformat格式化时间并输出(结果:2022-09-18 11:42:06)
console.log(dt.getFormatDate(new Date()));

##转义HTML中的特殊字符

//待转换的HTML字符串
const htmlStr = '<h3 style="display: none">首页</h3>&nbsp<span>天神</span>';
//调用htmlEscape方法进行转换
const str1 = dt.htmlEscape(htmlStr);
//转换的结果(&lt;h3 style=&quot;display: none&quot;&gt;首页&lt;/h3&gt;&amp;nbsp&lt;span&gt;天神&lt;/span&gt;)
console.log(str1);

##还原HTML中的特殊字符

//调用htmlUnEscape方法进行转换
const str2 = dt.htmlUnEscape(str1);
//转换的结果(<h3 style="display: none">首页</h3>&nbsp<span>天神</span>)
console.log(str2);

##开源协议 ISC