1.1.0 • Published 4 years ago

shiyi-tools v1.1.0

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

安装

npm install shiyi-tools

导入

const itheima = require("shiyi-tools");

格式化时间

// 调用 dateFormat 对时间进行格式化
const str = dt.dateFormat(new Date());
console.log(str);

转义 HTML 中的特殊字符

// 带转换的 HTML 字符串
const htmlStr =
  '<h1 class="ico">我是一个标题<span>我是个span&nbsp;</span></h1>';
// 调用 htmlEscape 方法进行转换
const strs = dt.htmlEscape(htmlStr);
console.log(strs);

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
const strss = dt.htmlUnEscape(strs);
console.log(strss);

开源协议

ISC