1.0.0 • Published 2 years ago

qt-tools v1.0.0

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

安装

npm install qt-tools

导入

const qtTools = require('qt-tools)

格式化时间

// 调用方法进行转换
const dtStr = qtTools.dateFormat(new Date())
console.log(dtStr)

转义html中的特殊字符

/// 调用htmlEscape方法进行转换
const html = qtTools.htmlEscape('<h1>"qt":我是望到头&</h1>')
// 转换的结果  &lt;h1&gt;&quot;qt&quot;:我是望到头&amp;&lt;/h1&gt;
console.log(html) 

待还原的html字符串

// 调用htmlUnEscape方法进行还原
const str = qtTools.htmlUnEscape(html)
// 转换的结果  <h1>"qt":我是望到头&</h1>
console.log(str)