1.0.0 • Published 3 years ago
youyehoho v1.0.0
安装
npm install itheima-tools-mine
导入
const itheima = require('itheima-tools-mine');
格式化
// 调用dateFormat
const dtStr = itheima.dateFormat(new Date);
// 打印结果 2020-12-29 20:12:35
console.log(dtStr);
转义HTML中的特殊字符
// 要转换的HTML字符串
const htmlStr = '<h1> title="abc">这是h1标签<span>123 </span></h1>';
// 转换后的字符串
const str = itheima.htmlEscape(htmlStr);
// 结果 <h1> title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(str);
还原HTML中的特殊符
// 要转换的字符
const newStr = itheima.htmlUnEscape(str);
// 转换后的结果 <h1> title="abc">这是h1标签<span>123 </span></h1>
console.log(newStr);
开源协议
ISC
1.0.0
3 years ago