1.0.0 • Published 2 years ago

itheima-tools-weizihuan v1.0.0

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

安装

npm install itheima-tools-weizihuan

导入

var weizihuan = require('itheima-tools-weizihuan')

格式化时间用法

// 调用dateFormat 方法格式化时间
var dtStr = weizihuan.dateFormat(new Date())
// 2023-06-23 19:35:52
console.log(dtStr)

html字符转义的用法

// 调用 htmlEscape 方法可以把 html 字符 进行转义
var htmlStr = '<h1>哈哈哈哈&nbsp哈哈<span>abc</span></h1>'
var str = weizihuan.htmlEscape(htmlStr)
// &lt;h1&gt;哈哈哈哈&amp;nbsp哈哈&lt;span&gt;abc&lt;/span&gt;&lt;/h1&gt;
console.log(str)

html字符还原的用法

var htmlStr = '&lt;h1&gt;&lt;/h1&gt;'
// 调用 htmlUnEscape 方法可以把 html 字符进行还原
var str2 = weizihuan.htmlUnEscape(htmlStr)
// <h1></h1>
console.log(str2)