seyuejuelie
v1.0.0
Published
提供了格式化时间,HtmlEscape相关功能
Downloads
2
Readme
##安装
npm install itheima-zyh-web47
##导入
const itheima require('itheima-zyh-web47')
##格式化
//调用dateFormat 对时间进行格式化
const dtStr = itheima.dateFormat(new Date())
//结果 2022年3月7日 22:56:51
console.log(dtStr)
##转义html中的特殊字符串
//待转换的html字符
const htmlstr = '<h1 title="abc>一个标签<span>123 </span></h1>'
//调用htmlescape方法进行转换
const str = itheima.htmlescape(htmlstr)
//转换结果<h1 title="abc>一个标签<span>123&nbsp;</span></h1>
console.log(str);
##还原html的特殊字符
//调用方法并转换字符
const un = itheima.htmlunescape(str)
//输出结果<h1 title="abc>一个标签<span>123 </span></h1>
console.log(un);
##开源协议 ISC