1.0.0 • Published 2 years ago

zjdheima-tools v1.0.0

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

##安装

npm install zjdheima-tools

##导入

const itheima = require('zjdheima-tools')

##格式化时间

// 调用dateFormat对时间进行格式化
const newStr = itheima.dateFormat(new Date())
console.log(newStr)  
// 结果2022-09-22 19:31:00

##转义html中的特殊字符

// 待转换的html字符
const htmlStr = <h1 title = "abc">h1标题<span>123&nbsp;</span></h1>
// 调用htmlEscape进行转换
const str = itheima.htmlEscape(htmlStr)
console.log(str)
// 结果&lth1 title = &quotabc&quot&gth1标题&ltspan&gt123&ampnbsp;&lt/span&gt&lt/h1&gt

##还原html中的特殊字符

// 待还原的html字符str

// 调用htmlUnEscape进行转换
const newStr = itheima.htmlUnEscape(str)
console.log(newStr)
// 结果<h1 title = "abc">h1标题<span>123&nbsp;</span></h1>

##开源协议 ICS