xie-tools

1.0.1 • Public • Published

安装包

npm install xie-tools

导入包

const df = require('xie-tools');

格式化时间

// 调用dateFormat方法
const d = df.dateFormat(new Date());
console.log(d);
结果:2022-12-05 22:30:08

转义html字符

//定义一个htmlStr 字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
// 调用htmlEscape方法
const str = df.htmlEscape(htmlStr);
console.log(str);
结果:&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原html字符

// 调用htmlUnEscape方法
const str1 = df.htmlUnEscape(str);
console.log(str1);
结果:<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i xie-tools

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

2.89 kB

Total Files

6

Last publish

Collaborators

  • xwb2001