zgdy_tols
Version:
提供格式化时间,HTMLEscape相关的功能
40 lines (30 loc) • 760 B
Markdown
## 安装包
```
npm install zgdy_tools
```
## 导入
```js
const zg = require("./zgdy_tools/index")
```
## 格式化时间
```js
const dt = new Date();
const newData = zg.dataForm(dt)
// 结果 2021-11-28 11:21:42
console.log(newData);
```
## 转义 HTML 中的特殊字符
```js
const htmlTxt = '<h1 title="abcd">我是h1标签<span>123 </span></h1>'
const str = zg.htmlEscape(htmlTxt);
// 结果 <h1 title="abcd">我是h1标签<span>123&nbsp;</span></h1>
console.log(str);
```
## 还原 HTML 中的特殊字符
```js
const unTxt = zg.htmlUnEscape(str);
// 结果 <h1 title="abcd">我是h1标签<span>123 </span></h1>
console.log(unTxt);
```
## 开源许可
ISC