zrzy123456 中文文档教程
安装
npm install gxzrzy
导入
const gxzrzy = require('gxzrzy')
格式化时间
// 调用 dateFormat 对时间进行格式化
const dtStr = gxzrzy.dateFormat(new Date())
// 结果 2020-04-03 17:20:58
console.log(dtStr)
转义 HTML 中的特殊字符
// 带转换的 HTML 字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
// 调用 htmlEscape 方法进行转换
const str = itheima.htmlEscape(htmlStr)
// 转换的结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(str)
还原 HTML 中的特殊字符
// 待还原的 HTML 字符串
const str2 = gxzrzy.htmlUnEscape(str)
// 输出的结果 <h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(str2)
开源协议
ISC
更多
你可能也喜欢
- 3t-element-ui 中文文档教程
- @1eeing/fetchonce 中文文档教程
- @500px_info/graphql-query-complexity 中文文档教程
- @5280software/lcu-testing-common 中文文档教程
- @5i5j/koa-service 中文文档教程
- @9renpoto/eslint-config-react 中文文档教程
- @aardvarkxr/aardvark-react 中文文档教程
- @aaxis/ma-ui 中文文档教程
- @abridged/web-wallet-client-sdk 中文文档教程
- @accelerator_one/shadow 中文文档教程