1.0.0 • Published 1 year ago

guigu_vue01_lj v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

npm install guigu_vue01_lj

导入

const tools = require('guigu_vue01_lj')

格式化时间

// 对指定日期进行格式化并输出
const dt = new Date()
console.log(tools.format(dt))

转义 HTML 中的特殊字符

// 转义 HTML 特殊字符串
// 例如:<h1 title="caption">这是一级标题</h1> 转义成 &lt;h1 title=&quot;caption&quot;&gt;这是一级标题&lt;h1&gt;
const htmlStr_escape = '<h1 title="caption">这是一级标题</h1>'
const result_escape = tools.escape(htmlStr_escape)
console.log(result_escape)

还原 HTML 中的特殊字符

// 转义 HTML 特殊字符串
// 例如:<h1 title="caption">这是一级标题</h1> 转义成 &lt;h1 title=&quot;caption&quot;&gt;这是一级标题&lt;h1&gt;
const htmlStr_unescape = '&lt;h1 title=&quot;caption&quot;&gt;这是一级标题&lt;h1&gt;'
const result_unescape = tools.unEscape(htmlStr_unescape)
console.log(result_unescape);

开源协议

ISC

1.0.0

1 year ago