itlyx-utils
v1.0.0
Published
提供格式化事件 HTMLEscape相关的功能
Downloads
3
Readme
安装
npm install itlyx-utils
导入
const itlyx = require('itlyx-utils')
格式化时间
// 调用 dataFormat 对时间进行格式化
const dt = itlyx.dataFormat(new Date)
// 2022-03-24 22-37-10
console.log(dt)
转义html 字符串的方法
// 定义一个常量 保存 html 字符串
const html = '<h1 title="abc">这是h1标签<span>123$gt; </span></h1>'
// 调用htmlEacape 对 html字符串 进行转义
const str = itlyx.htmlEacape(html)
// 结果:<h1 title="abc">这是h1标签<span>123$gt;&nbsp</span></h1>
console.log(str)
还原html 字符串的方法
// str = $lt;h1 title="abc">这是h1标签$lt;span>123$gt;&nbsp$lt;/span>$lt;/h1>
const htmlun = itlyx.htmlunEacape(str);
// 结果: <h1 title="abc">这是h1标签<span>123$gt;&nbsp</span></h1>
console.log(htmlun)