xinxin1

提供了格式化时间、htmlEscape相关功能

Usage no npm install needed!

<script type="module">
  import xinxin1 from 'https://cdn.skypack.dev/xinxin1';
</script>

README

安装

npm i xinxin1

导入

const xinxin = require('xinxin')

格式化时间的功能

//调用 dateFormat 方法
const dtStr =TIME.dateFormat(new Date())
//调用的结果 2020-11-28 15:40:39
console.log(dtStr);

转义 html字符 方法

const h1 = '< h1 > 123"567" &nbsp; 78</h1 > '
//调用 htmlEscape 方法
let str = HTML.htmlEscape(h1)
//调用结果 &lt; h1 &gt; 123&quot;567&quot; &amp;nbsp; 78&lt;/h1 &gt;
console.log(str);

还原 html字符 方法

const h1 = '&lt; h1 &gt; 123&quot;567&quot; &amp;nbsp; 78&lt;/h1 &gt; '
//调用 unhtmlEscape 方法
let str = HTML.unhtmlEscape(h1)
//调用结果 < h1 > 123"567" &nbsp; 78</h1 >
console.log(str);

协议

ISC