Package Exports
- itheima-taols-ddjs1
- itheima-taols-ddjs1/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-taols-ddjs1) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
安装
npm i ithei-tools-ddjs
导入
const itheima = require('ithei-tools-ddjs')
格式化时间
const dtStr = itheima.dateFormat(new Date())
//结果:2022-03-23 14:05:28
console.log(dtStr)
转义 html 中的字符
//带转换的 html 字符串
const htmlStr = '<h1 title="abc">我是 h1<span>123 </span></h1>'
//调用 htmlEscape 方法进行转换
const str = idheima.htmlEscape(htmlStr)
//结果:<h1 title="abc">我是 h1<span>123&nbsp</span></h1>
console.log(str)
原转义的 html 字符串
//带还原的字符串调用 htmlUnEscape 方法进行转换
const str2 = idheima.htmlUnEscape(str)
//结果:<h1 title="abc">我是 h1<span>123&nbsp</span></h1>
console.log(str2)
开源协议
ISC