1.0.0 • Published 5 years ago
itheima-utils-fei v1.0.0
使用说明
安装方式
npm install itheima-utils-fei
导入方式
const f1 = require('./itheima-utils-fei/index');
格式化时间
const temp = new Date();
//未格式化时间 2020-03-05T09:31:57.847Z
const t1 = f1.dateFormat(temp);
//格式化时间 2020-03-05 17:31:57
转义 HTML 中的特殊字符
//待转换的 HTML 字符串
const temp = '<h1 style="color: red;">你好!©<span>小黄!</span></h1>'
//调用 htmlEscape 进行转换
const str = f1.htmlEscape(temp);
//输出 <h1 style="color: red;">你好!&copy;<span>小黄!</span></h1>
console.log(str);
还原 HTML 中的特殊字符
const html = f1.htmlUnescape(temp);
//输出 <h1 style="color: red;">你好!©<span>小黄!</span></h1>
console.log(html);
开源协议
1.0.0
5 years ago