1.0.0 • Published 2 years ago

seyuejuelie v1.0.0

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

##安装

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&nbsp;</span></h1>'
//调用htmlescape方法进行转换
const str = itheima.htmlescape(htmlstr)
//转换结果&lth1 title=&quotabc&gt一个标签&ltspan&gt123&ampnbsp;&lt/span&gt&lt/h1&gt
console.log(str);

##还原html的特殊字符

//调用方法并转换字符
const un = itheima.htmlunescape(str)
//输出结果<h1 title="abc>一个标签<span>123&nbsp;</span></h1>
console.log(un);

##开源协议 ISC