1.0.0 • Published 3 years ago
itqinjiu-tools v1.0.0
安装
npm i itqinjiu-tools
导入
const itqinjiu = require('itqinjiu-tools')
const htmlSwitch = require('./itqinjiu-tools')
const html = require("./itqinjiu-tools")
格式化时间
// 调用 deteTime 对时间格式化
const dtStr = itqinjiu.dateTime(new Date())
// 结果 2022-11-17 10:28:15
console.log(dtStr)
转义 HTML 中的字符串
// 待转换的字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
// 调用对应的方法 htmlEscape 进行转换
const str = htmlSwitch.htmlEscape(htmlStr)
// 结果 <h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(str);
还原 HTML 中字符串
// 待还原的字符串
const htmls = '<h1 title="abc" >这是h1标签<span >123 </span></h1 >'
// 调用对应的 rehtml 方法进行转换
const rehtmls = html.rehtml(htmls)
// 结果 <h1 title="abc"> 这是h1标签<span>123 </span></h1>
console.log(rehtmls);
开源协议
ISC
1.0.0
3 years ago