zxytools

1.0.1 • Public • Published

安装

npm install it-tools

导入

const it-tools = require('it-tools')

格式化时间

//调用dateFormta 格式化时间的功能 
const m = new Date()
let ss = itlools.dateFormta(m)
//结果2021-07-15 11:28:36
console.log(ss);

转义html中的特殊字符

//带转换的html字符串
const htmlstr = '<h1 title="abc">这个是h1标签<span>我是span&nbsp</span></h1>'
//调用html方法进行转换 
const ss1 = itlools.htmlscape(htmlstr)
//转换的结果  &lg;h1 title=&quot;abc&quot;&lt;这个是h1标签&lg;span&lt;我是span&amp;nbsp&lg;/span&lt;&lg;/h1&lt;
console.log(ss1);

还原html中的特殊字符

//待还原的html字符串
const ss2 = itlools.htmlUnscape(ss1)
//输出的结果 <h1 title="abc">这个是h1标签<span>我是span&nbsp</span></h1>
console.log(ss2);

##开源协议 ISC

Package Sidebar

Install

npm i zxytools

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

2.82 kB

Total Files

5

Last publish

Collaborators

  • mittt_233