1.0.0 • Published 2 years ago

ithima-fishy v1.0.0

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

安装

npm install itheima-fishy

导入

const itheima = require('itheima-fishy')

格式化时间

// 调用dateFormat对时间进行格式化
const dtStr = ithema.dateFormat(new Date())
// 打印输出格式化后的时间字符串
console.log(dtStr)

转义html中的特殊字符

// 待转换的html字符串
const htmlStr = '<div style="color:red">商品名称:&nbsp;葡萄</div>'
// 调用htmlEscape进行转换
const str = itheima.htmlEscape(htmlStr)
// 转换的结果 &lt;div style=&quot;color:red&quot;&gt;商品名称:&amp;nbsp;葡萄&lt;/div&gt;
console.log(str);

开源协议

ISC