itheima-yzh-tools

1.0.0 • Public • Published

##安装

npm install itheima-yzh-tools

##导入

const itheima=require('./itheima-yzh-tools/index')

##格式化时间函数

const dt=new Date()
//用dateFormat方法对时间进行初始化
const newDT=itheima.dateFormat(dt)
//输出结果:2022-11-15 11:42:37
console.log(newDT)

##转义HTML中的特殊字符

const htmlStr="<h1>这是一个h1标签<span>span标签&nbsp;</span></h1>"
//用htmlEscape方法转义HTML中的特殊字符
const escape=itheima.htmlEscape(htmlStr)
//输出结果:&lt;h1&gt;这是一个h1标签&lt;span&gt;span标签&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(escape)

##还原HTML中的特殊字符

//用htmlUnEscape方法还原HTML中的特殊字符
const unEscape=itheima.htmlUnEscape(escape)
//输出结果:<h1>这是一个h1标签<span>span标签&nbsp;</span></h1>
console.log(unEscape)

##开源格式 ISC

Package Sidebar

Install

npm i itheima-yzh-tools

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.7 kB

Total Files

5

Last publish

Collaborators

  • yuzhenhui