1.0.0 • Published 2 years ago
itheima-tools-wq v1.0.0
安装
npm install itheima-tools-wq
导入
const itheima = require("./itmeima-tools/index")
格式化时间
// 调用格式化时间函数
const dt = itheima.dataFromat(new Date())
console.log(dt);
//输出结果2022-05-04 21:14:53
转义HTML中的特殊字符
// 待转义的字符
const htmlstr = ' <h1>首页<span>123</span></h1>'
// 调用函数进行转义
const str = itheima.htmlEscape(htmlstr)
console.log(str);
//输出结果&nbsp<h1>首页<span>123</span></h1>
还原HTML中的特殊字符
// 调用函数转义还原字符
const str1 = itheima.htmlUnEscape(str)
console.log(str1);
//输出结果 <h1>首页<span>123</span></h1>
开源协议
"license": "ISC"
1.0.0
2 years ago