```js npm install itheima-demo-lx ``` ## 导入 ```js const itheima = require('itheima-demo-lx') ```
npm install itheima-demo-lxjs
npm install itheima-demo-lx
`
导入
`js
const itheima = require('itheima-demo-lx')
`
格式化时间
`js
// 调用时间格式化方法
const dt =itheima.formDate(new Date());
// 结果 2020-10-14 15:58:39
console.log(dt);
`
转义html中的特殊字符
`js
// 调用转义html中的特殊字符方法
const htmlStr = itheima.htmlIEscape('Hello Mymodule!
')
// 结果 <h1 style="color:green;">Hello Mymodule!</h1>
console.log(htmlStr);
`
还原html中的特殊字符
`js
const htmlStr = itheima.htmlUnEscape('<h1 style="color:green;">Hello Mymodule!</h1>')
// 结果 Hello Mymodule!
console.log(htmlStr);
``