Package Exports
- itheima-shanhu
- itheima-shanhu/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-shanhu) 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-shanhu
导入
const itheima = require('itheima-shanhu')
格式化时间
const dt = itheima.dateFormat(new Date())
// 输出 2020-01-20 10:47:32
console.log(dt)
转义 HTML 中的特殊字符
// 待转换的 HTML 字符串
const htmlStr = '<h1 style="color: red;">你好!©<span>小黄!</span></h1>'
// 调用 htmlEscape 进行转换
const str = itheima.htmlEscape(htmlStr)
// 输出 <h1 style="color: red;">你好!&copy;<span>小黄!</span></h1>
console.log(str)
还原 HTML 中的特殊字符
const rawHTML = itheima.htmlUnEscape(str)
// 输出 <h1 style="color: red;">你好!©<span>小黄!</span></h1>
console.log(rawHTML)