Package Exports
- itheima-tools-zgf
- itheima-tools-zgf/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (itheima-tools-zgf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
安装
npm install itheima_tools_zgf
导入模块
// 导入模块
const itheima_zgf = require('./index');
格式化时间
// 格式化时间:
console.log(itheima_zgf.dateformat());
// 输出结果:2022-07-16 - 11:48:26
转义html特殊字符
//准备字符串
const htmlstr = '<h1 title="abc">我是h1标签<span>&&123我是span</span></h1>';
// 转义html特殊字符
console.log(itheima_zgf.htmlescape(htmlstr));
// 输出结果:$lth1 title="abc"$gt我是h1标签$ltspan$gt&&123我是span$lt/span$gt$lt/h1$gt
还原html特殊字符
//准备字符串
const str = '<h1 title="abc">我是h1标签<span>&&123我是span</span></h1>';
// 还原html特殊字符
console.log(itheima_zgf.htmlUnescape(str));
// 输出结果:<h1 title="abc">我是h1标签<span>&&123我是span</span></h1>
开源协议
ISC