开发属于自己的包 初始化包的基本结构 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)
const str = '
'const shift = itheima.htmlEscape(str)
console.log(shift)
const str2 = itheima.htmlUnEscape(str)
console.log(str2)
ISC