1.0.0 • Published 2 years ago

bywq_tool v1.0.0

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

安装

npm install wqtool

导入

const wtool = require('wqtool')

格式化时间

// 调用格式化时间的方法
const date = wtool.dateFormat(new Date())
console.log(date);
// 结果 2022-08-05 10:41:53

转义HTML中的特殊字符

// 带转换的HTML字符串
const htmlStr = '<h1>我是h1标题<span title="12345">12345&</span></h1>'
// 调用htmlEscape方法进行转换
const str  = wqtool.htmlEscape(htmlStr) 
console.log(str)
// 转化结果  &lt;h1&gt;我是h1标题&lt;span title=&quot;12345&quot;&gt;12345&amp;&lt;/span&gt;&lt;/h1&gt;

还原转义的html字符串

const str = '&lt;h1&gt;我是h1标题&lt;span title=&quot;12345&quot;&gt;12345&amp;&lt;/span&gt;&lt;/h1&gt;'

// 调用还原转义的方法
const result = wqtool.htmlUnEscape(str)

console.log('result')

// 转化结果  <h1>我是h1标题<span title="12345">12345&</span></h1>

开源协议

IIC

1.0.0

2 years ago