zyx-tools
Version:
提供了格式化时间、HTMLEscape相关功能
39 lines (30 loc) • 837 B
Markdown
## 安装
```
npm install zyx-tools
```
##导入
```js
const zyxTools = require('zyx-tools');
```
##格式化时间
```js
//格式化时间功能
const dtstr = zyxTools.dateFormate(new Date());
//结果 2023-09-10 11:34:16
```
##转移 HTML 中的特殊字符
```js
//待转换的htm1字符串
const htmlstr ='<h1 title="abc">这是h1标签<span>123 </span></h1>';
const str= zyxTools.htmlEscape(htmlstr);
// 结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
```
##还原 HTML 中的特殊字符
```js
//待还原的htm1字符串
const str ="<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>";
const htmlStr = zyxTools.htmlEscape(str);
//结果<h1 title="abc">这是h1标签<span>123 </span></h1>
```
##开源协议
ISC