1.0.0 • Published 5 years ago
itheima-panstarry v1.0.0
安装
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 </span></h4>'
// 调用 zhuanYi 对 htmlStr 进行转义
const str = itheima.zhuanYi(htmlStr)
// 结果是: &glt;h4 title="abc">这是h4标签&glt;span>123&nbsp;&glt;/span>&glt;/h4>
console.log(str);
还原 HTML 中的特殊字符
// 调用 zhuanHui 还原 str 的特殊字符
const strs = itheima.zhuanHui(str)
// 结果是:<h4 title="abc">这是h4标签<span>123 </span></h4>
console.log(strs);
1.0.0
5 years ago