it-good

1.0.0 • Public • Published

安装

npm install it-good

导入

const it = require('./itheima-tools/index')

格式化时间

const dt = new Date()
//调用格式化时间功能
const dtStr = it.dateFormat(dt)
//输出结果 2022-09-10 10:24:02
console.log(dtStr)

转义 HTML 中的特殊字符

//调用转义字符串函数
const htmlStr = '<h1 style="color: brown">这是一个h1标签<span>123span标签$nbsp;</span></h1>'
const str = it.htmlEscape(htmlStr)
//输出结果 &lt;h1 style=&quot;color: brown&quot;&gt;这是一个h1标签&lt;span&gt;123span标签$nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str)

转义 HTML 中的特殊字符

//调用还原字符串函数
const str2 = it.htmlUnEscape(str)
//输出结果 <h1 style="color: brown">这是一个h1标签<span>123span标签$nbsp;</span></h1>
console.log(str2)

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i it-good

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

2.89 kB

Total Files

5

Last publish

Collaborators

  • zhengrenheng