mytools-utils

1.5.8 • Public • Published

安装

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i mytools-utils

      Weekly Downloads

      2

      Version

      1.5.8

      License

      ISC

      Unpacked Size

      3.05 kB

      Total Files

      6

      Last publish

      Collaborators

      • doroxinrui