1.0.0 • Published 5 years ago
yjx-itheima-tools v1.0.0
itheima-tools 使用说明
安装
npm i itheima-tools
导入
const itheima = require('itheima-tools');
格式化时间
// 调用 dateFormat() 格式化时间方法
const dt = itheima.dateFormat(new Date());
// 2020-03-04 16:01:47
console.log(dt);
html特殊字符转义 <, >, ", &
// 需要转义的字符
const htmlStr = '<h1 style="color: red;">我是一个<span>傻逼&</span></h1>'
// 调用 htmlEscape() 方法
const str = itheima.htmlEscape(htmlStr);
// <h1 style="color: red;">我是一个<span>傻逼&</span></h1>
console.log(str);
html特殊字符还原 <, >, ", &
// 需要转义的字符
const str = '<h1 style="color: red;">我是一个<span>傻逼&</span></h1>'
// 调用 htmlEscape() 方法
const htmlStr = itheima.htmlEscape(htmlStr);
// <h1 style="color: red;">我是一个<span>傻逼&</span></h1>
console.log(htmlStr);
开源协议
https://img.shields.io/npm/l/express?registry_uri=https%3A%2F%2Fregistry.npmjs.com
1.0.0
5 years ago