1.0.0 • Published 5 years ago

itheima-tools-wll v1.0.0

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

安装

npm install itheima-tools

导入

const inteima = require('itheima-tools')

格式化时间

// 调用 dateFormate 对时间进行格式化
const dtStr = ihteima.dateFormate(new Date())
console.log(dtStr);

转义html中的特殊字符

// 待转换的 HTMl 字符串
const htmlStr = '<h1 title="h1">这是H1标签</h1>';
// 调用 htmlEscape 方法 进行转换
const str =  ihteima.htmlEscape(htmlStr);
// 结果 &glt;h1 title=&quot;h1&quot;&gt;这是H1标签&glt;/h1&gt;
console.log(str);

还原HTML中的特殊字符

// 待还原的 HTMl 字符串
const str2 = ihteima.htmlUnEscape(str);
//  结果 <h1 title="h1">这是H1标签</h1>
console.log(str2);

开源协议

ISC

1.0.0

5 years ago