1.0.0 • Published 1 year ago

itheima-tools-cuicui v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

npm install itheima-tools-cuicui

导入

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

格式化时间

//调用 dataFormat 对时间进行格式化
const dateStr = itheima.dateFormat(new Date())
//结果 2023-01-00 18:52:28
console.log(dateStr);

转义html中的特殊字符

//定义待转换的字符串
let str = '<h1>hello</h1>'
//调用 htmlEscape 对字符串进行转换
str = itheima.htmlEscape(str);
//结果 &lth1&gthello&lt/h1&gt
console.log(str);

还原html中的特殊字符

//定义待还原的字符串
let htmlstr1 = '&lth1&gthello&lt/h1&gt';
//调用 htmlUnEscape 对字符串进行还原
htmlstr1 = itheima.htmlUnEscape(htmlstr1);
//结果 <h1>hello</h1>
console.log(htmlstr1);

开源协议

ISC