1.0.0 • Published 2 years ago

itheima-tools-userxgk v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

npm install itheima-tools-userxgk

导入

const itheima = require('itheima-tools-userxgk')

格式化时间

//调用dateformat对时间进行格式化
const s1 = require('./index').dataformat(new Date())
console.log(s1);
//2023-05-22 15:40:52

转义 HTML 中的特殊字符

//定义待转换的html字符串
const str = '<h1 title="abc">这是h1标签<span>13&nbsp;</span></h1>'
// 调用htmlEscape方法进行转换
const s2 = require('./index').htmlEscape(str)
//&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;13&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(s2);

还原 HTML 中的特殊字符

// 待还原的html字符串
const str = '<h1 title="abc">这是h1标签<span>13&nbsp;</span></h1>'
// 调用htmlEscape方法进行转换
const s3 = require('./index').htmlUnscape(str)
// <h1 title="abc">这是h1标签<span>13&nbsp;</span></h1>
console.log(s3);

开源协议

ISC