1.0.0 • Published 3 years ago

hwc-tools v1.0.0

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

安装

npm i HWC-tools

导入

const tools = require('hwc-tools')

格式化时间

const time = abc.dataFormate(new Date())
console.log(time);

转义HTML 特殊字符

const htmlStr = '<h1 title="abc">我是你爹</h1>'
// 转义为字符编码
let str = abc.htmlEscape(htmlStr)
// &lt;h1 title=&quot;abc&quot;&gt;我是你爹&lt;/h1&gt;

转回 HTML 格式

const htmlStr = '<h1 title="abc">我是你爹</h1>'
// 转义为字符编码
let str = abc.htmlEscape(htmlStr)
// &lt;h1 title=&quot;abc&quot;&gt;我是你爹&lt;/h1&gt;
// 转义回html
 str = abc.unEscapeHtml(str)
 //<h1 title="abc">我是你爹</h1> 

开源协议

ISC