1.0.0 • Published 2 years ago
itheima-tools-weizihuan v1.0.0
安装
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>哈哈哈哈 哈哈<span>abc</span></h1>'
var str = weizihuan.htmlEscape(htmlStr)
// <h1>哈哈哈哈&nbsp哈哈<span>abc</span></h1>
console.log(str)
html字符还原的用法
var htmlStr = '<h1></h1>'
// 调用 htmlUnEscape 方法可以把 html 字符进行还原
var str2 = weizihuan.htmlUnEscape(htmlStr)
// <h1></h1>
console.log(str2)
1.0.0
2 years ago