creself-tools
v1.1.0
Published
提供了格式化时间,格式化特殊字符等功能
Downloads
3
Maintainers
Readme
安装
npm install creself-tools
导入
const creself=require('creself-tools')
格式化时间
//调用dataFormat对时间进行格式化
const dtStr = self.dataFormat(new Date())
console.log('格式化时间结果' + dtStr);
//格式化时间结果2021-10-29 13:17:47
转义html中的特殊字符
//定义了待转化的html字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
const str = self.htmlEscape(htmlStr)
console.log('转义之后' + str);
//输出结果
// 转义之后<h1 title="abc">这是h1标签<span>123&apm;nbsp;</span></h1>
还原html特殊字符
//待还原html字符串
const str2 = self.htmlUnescape(str)
console.log('还原之后' + str2);
// 结果 还原之后<h1 title="abc">这是h1标签<span>123 </span></h1>
开源协议
ISC