1.0.0 • Published 3 years ago

itheima-tools-dsj v1.0.0

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

##安装方式

npm install itheima-tools-dsj

##导入方式

const dsj = require("itheimaitheima-tools-dsj");

##格式化时间

//将时间格式化的方法
const dtStr = dsj.dateFormat(new Date());
//2021-09-29 08:44:48
console.log(dtStr);

##转义 HTML 中的特殊字符

//HTML字符串
const htmlstr = '<h1 class="a">我是首页<span>123&nbsp;</span></h1>';
//调用htmlEscape方法转换
const str = dsj.htmlEscape(htmlstr);
//转换的结果:&lt;h1 class=&quot;a&quot;&gt;我是首页&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str);

##还原 HTML 中的特殊字符

//调用htmlUnEscape方法还原特殊字符串
const str2 = dsj.htmlUnEscape(str);
//输出的结果:<h1 class="a">我是首页<span>123&nbsp;</span></h1>
console.log(str2);

##开源协议 ISC