1.0.1 • Published 2 years ago
sc-tools v1.0.1
安装
npm i sc-tools
导入
const utils = require('sc-tools')
格式化时间
// 调用 dateFormat 对时间进行格式化
const dtStr = utils.dateFormat(new Date())
// 结果: 2022-06014 23:10:10
console.log(dtStr)
格式化时间
// 调用 dateFormat 对时间进行格式化
const dtStr = utils.dateFormat(new Date())
// 结果: 2022-06014 23:10:10
console.log(dtStr)
转义 HTML 中的特殊字符
// 待转换的 HTML 字符串
const htmlStr = `<h1 title="abc"><span>123 </span></h1>`
// 调用 htmlEscape 进行转化
const str = utils.htmlEscape(htmlStr)
// 结果: <h1 title="abc"><span>123&nbsp;</span></h1>
console.log(str)