Package Exports
- itheima-tools-zm
- itheima-tools-zm/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-zm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
install
... npm install itheima-tools-zm ...
import
...js const itheima = require('itheima-tools-zm') ...
格式化时间
...js // 调用dateFormat对时间进行格式化 const dt = itheima.dateFormat(new Date()) // 结果 2022-04-02 23:59:03 console.log(dt) ...
转义html中的特殊字符
...js // 带转换的HTML的字符串 const htmlStr = '
这是h1标签123
' // 调用htmlEscape方法进行转换 const str = itheima.htmlEscape(htmlStr) // 转换的结果 <h1 title="ABC">这是h1标签<span>123 </span></h1> console.log(str) ...还原html中的特殊字符
...js // 待还原html中的字符串 const unStr = itheima.htmlUnEscape(str) // 输出结果
这是h1标签123
console.log(unStr) ...开源协议
ISC