1.0.0 • Published 5 years ago

itheima-panstarry v1.0.0

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

安装

npm i itheima-tools

导入

const itheima = require('./itheima-panstarry')

格式化时间

// 调用dateForat 函数对时间进行格式化
const s = itheima.dateFormat(new Date())
// 结果是: 2020-08-21 20:27:33
console.log(s);

转义HTML 标签

// 带转义的文字
const htmlStr = '<h4 title="abc">这是h4标签<span>123&nbsp;</span></h4>'
// 调用 zhuanYi 对 htmlStr 进行转义
const str = itheima.zhuanYi(htmlStr)
// 结果是: &glt;h4 title=&quot;abc&quot;&gt;这是h4标签&glt;span&gt;123&amp;nbsp;&glt;/span&gt;&glt;/h4&gt;
console.log(str);

还原 HTML 中的特殊字符

// 调用 zhuanHui 还原 str 的特殊字符
const strs = itheima.zhuanHui(str)
// 结果是:<h4 title="abc">这是h4标签<span>123&nbsp;</span></h4>
console.log(strs);
1.0.0

5 years ago