itheima-tools-zxy

1.0.0 • Public • Published

开发属于自己的包 初始化包的基本结构 1.新建 创建自己的包tool 文件夹,作为包的根目录 2.在 创建自己的包tool 文件夹,新建如下三个文件: package.json(包管理配置文件) index.js(包的入口文件) README.md(包的说明文档)

package.json中的解释:
    name:别人要require时所提交的名字
    verson:版本号
    main:指定包的入口文件
    description:简短的描述信息
    keywords:搜索的关键字
    license:包所遵循的开源协议 默认就是ISC

安装

npm install itheima-tools

导入

const itheima = require('itheima-tools')

格式化时间

const dtStr = itheima.dateFormat(new Date())

console.log(dtStr)

转义 HTML 中的特殊字符

const str = '

这是h1标签123 

'

const shift = itheima.htmlEscape(str)

console.log(shift)

还原 HTML 中的特殊字符

const str2 = itheima.htmlUnEscape(str)

console.log(str2)

开源协议

ISC

Package Sidebar

Install

npm i itheima-tools-zxy

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

3.41 kB

Total Files

5

Last publish

Collaborators

  • zhaoyu1314