itheima-utils-lcc

1.0.0 • Public • Published

安装

npm install itheima-utils-lcc

导入

const lcc = require('itheima-utils-lcc')

格式化时间

//格式化时间
const time = lcc.dataFromat(new Date())
//2023年04月19日 16时35分38秒
console.log(time)

转译HTML字符串

//定义要转换的字符串
const htmlstr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
//转换字符串
const str = lcc.htmlEscape(htmlstr)
//&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str);

还原HTML字符串

//定义要还原的字符串
const htmlstr = '&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;'
//还原字符串
const str= lcc.htmlunEscape(htmlstr)
//<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(str);

生成随机数

//括号内为要生成的随机数范围M-N
let r =lcc.getRandom(1,10)
//4
console.log(r);

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i itheima-utils-lcc

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

3 kB

Total Files

6

Last publish

Collaborators

  • zk3314400372