1.0.0 • Published 5 years ago
zx_tools v1.0.0
安装方式
npm install zx_tools
导入
const zx_tools = require('zx_tools')
格式化时间
// 待格式化的时间
const oldDate = new Date()
// 调用 dateFormat 对时间进行格式化
const newDate = my.dateFormat(oldDate)
// 结果 2020-07-03 00:05:40
console.log(newDate);
转义 HTML 中的特殊字符串
// 待转换的 HTML 字符串
const htmlStr = '<h1 title="abc">你好</h1>'
// 调用 htmlEscape 方法进行转换
const str1 = my.htmlEscape(htmlStr)
// 转换结果 <h1 title="abc">你好</h1>
console.log(str1);
还原 HTML 中的特殊字符串
// 待还原的 HTML 字符串
const str2 = my.htmlUnEscape(str1)
// 还原结果 <h1 title="abc">;你好</h1>;
console.log(str2);
开源协议
ISC
1.0.0
5 years ago