1.0.0 • Published 2 years ago

itheima-tools4 v1.0.0

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

说明文档

这是一个自定义的包文件;

主要实现三个功能;

1. 格式化日期
2. 转义 HTML 的特殊字符
3. 还原 HTML 的特殊字符 

安装方式

npm i itheima-tools4

导入方式

const tools = require('itheima-tools4');

格式化时间

const time = tools.dataFormat() 
//显示被格式化的时间,补0的

转化html中特殊字符

const b = '<html> <body>1111222333</body> </html>'
const c = tools.htmlStr(b)
console.log(c) //返回被格式化的内容
//输出 &lt;html&gt; &lt;body&gt;1111222333&lt;&#47;body&gt; &lt;&#47;html&gt;

还原html中特殊字符

const b = '&lt;html&gt; &lt;body&gt;1111222333&lt;&#47;body&gt; &lt;&#47;html&gt;'
const c = tools.htmlRes(b)
console.log(c) //返回被格式化的内容
//'<html> <body>1111222333</body> </html>'

开源协议

MIT