1.0.1 • Published 2 years ago

itchefeng-tools v1.0.1

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

安装

npm install itchefeng-tools

导入

const dt = require('./itchefeng-tools/index')

格式化时间

// 调用dateFormat 对时间进行格式化
const dtStr = dt.dateFormat(new Date())
// 结果 222022-10-03 16:56:07
console.log(dtStr);

转义HTML中的特殊字符

// 带转换的HTML字符串
const htStr = '<h1 title="abc">我是h1标签<span>我是span标签</span></h1>'
// 调用htmlEscape方法进行转换
const newHtstr = dt.htmlEscape(htStr)
// 转换的结果 &lt;h1 title=&quot;abc&quot;&gt;我是h1标签&lt;span&gt;我是span标签&lt;/span&gt;&lt;/h1&gt;

还原HTML中的转义字符

// 带转换的转义字符串 &lt;h1 title=&quot;abc&quot;&gt;我是h1标签&lt;span&gt;我是span标签&lt;/span&gt;&lt;/h1&gt;
// 调用htmlUnEscape方法进行转换
const newStr = dt.htmlUnEscape(newHtstr)
// 转换的结果
<h1 title="abc">我是h1标签<span>我是span标签</span></h1>

开源协议

ISC

1.0.1

2 years ago

1.0.0

2 years ago