1.5.8 • Published 2 years ago

mytools-utils v1.5.8

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

安装

npm install mytools-utils

导入

const mytools = require('mytools-utils')

格式化时间

//调用dateFormat对时间进行格式化
const dtStr = mytools.dateFormat(new Date())
//结果 2022-06-06 17:45:48
console.log(dtStr)

转义 HTML 中的特殊字符

//带转换的HTML字符串
const htmlStr = '<h1 title = 'abc'>这是一个h1标签</h1>'
//调用htmlEscape方法进行转换
const str = htmlStr.htmlEscape(htmlStr);
//转换的结果:&lth1 class = &quotdorothy&quot&gt这是一个h1标签&ltspan&gt&lt/span&gt&lt/h1&gt

## 还原HTML中的特殊字符
```js
//带还原的字符串
const str1 = mytools.htmlUnescape(str)
//输出的结果
console.log(str1)

开源协议

ISC