myprovide-tools

1.0.0 • Public • Published

安装

npm install itheima-tools

导入

const utils = require('myprovide-tools')

格式化时间

// 调用 dataFormat 对时间进行格式化

const dtStr = utils.dateformat(new Date())

//结果 2022-10-23 17:07:27

console.log(dtStr)

转义 HTML 中的特殊字符

// 调用 htmlEscape 方法进行转换

const dtStr = utils.htmlEscape('<h1 title="nihao">你好</h1>')

// 结果 &lt;h1 title=&quot;nihao&quot;&gt;你好&lt;/h1&gt;

还原 HTML 中的特殊字符

// 调用 htmlEscape 方法进行转换

const dtStr = utils.htmlUnEscape('&lt;h1 title=&quot;nihao&quot;&gt;你好&lt;/h1&gt;')

// 结果 <h1 title="nihao">你好</h1>

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i myprovide-tools

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.25 kB

Total Files

5

Last publish

Collaborators

  • shiziyaya