1.0.0 • Published 1 year ago
cjj-tools v1.0.0
安装
npm install cjj-tools
导入
const cjj_tools = require('cjj-tools')
格式化时间
const date = cjj_tools.formatDate(new Date)
// 转换后的结果: 2022-12-28 23:18:51
转换 HTML 字符串中的特殊字符
// 转换前的HTML字符串
const htmlStr = '<h1 style="">asdfasd </h1>'
// 转换后的结果: <h1 style="">asdfasd&nbsp;</h1>
console.log(cjj_tools.htmlEscape(htmlStr));
还原 HTML 字符串中的特殊字符
// 转换前的字符串
const htmlUnStr = '<h1 style="">asdfasd&nbsp;</h1>'
// 转换后的结果: <h1 style="">asdfasd </h1>
console.log(cjj_tools.htmlUnEscape(htmlUnStr));
开源协议
ISC
1.0.0
1 year ago