1.0.0 • Published 4 years ago

itheima36-tools v1.0.0

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

##安装

npm i itheima36-tools

##导入

const itheima = require('./itheima36-tools')

##格式化时间

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

##转义html中的特殊字符

//待转换的字符串
const htmlStr = `<h1 style="color:red">这是h1标签<span>123&nbsp;</span></h1>`
//调用htmlEscape方法进行转换
const str = itheima.htmlEscape(htmlStr)
//结果&lt;h1 style=&quot;color:red&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str);

##还原html中的特殊字符

//待还原的字符串
const rawHTML = itheima.htmlUnEscape(str)
//结果<h1 style="color:red">这是h1标签<span>123&nbsp;</span></h1>
console.log(rawHTML);

##开源协议 ISC

1.0.0

4 years ago