1.0.0 • Published 3 years ago

itheima-tools-uphy v1.0.0

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

#安装

npm install itheima-tools-uphy

#导入

const itheima = require('itheima-tools-uphy')

#格式化时间

//调用 dateFormat 对时间进行格式化
const dtstr = itheima_hy.dateFormat(new Date())
//结果 2022-4-15 17:59:37

##转义特殊字符

// 待转换 HTML 字符串
const htmlstr = '<h1 title="abc">则是h1标签<span>123</span></h1>'
// 调用htmlEscape 方法进行转换
const str = itheima_hy.htmlEscape(htmlstr)
// 转换的结果 &lth1 title=&quotabc&quot&gt则是h1标签&ltspan&gt123&lt/span&gt&lt/h1&gt
console.log(str2);

#还原HTML 中的转义字符

// 待还原到 HTML 字符串
const str2 = itheima_hy.htmlUnEscape(str)
//还原后的结果 <h1 title="abc">则是h1标签<span>123</span></h1>
console.log(str2);

##开源协议 ISC