Utils
JavaScript工具库.
说明
- 此工具库是自己从事前端开发以来整理和完善的,里面有些函数可以用 Underscore 和 lodash 代替。
- 由 typescript 编写,并编译为一份 ESnext 和 CommonJs 的代码。 所以如果引入到您的项目中使用,需搭建好 babel 编译环境。
- 借助于 tree shaking 可以不用担心导入多余的代码。
安装
npm i -S @forgleaner/utils
文档
具体用法可查看import { ToDecimal } from '@forgleaner/utils';
let num = 120;
console.log(ToDecimal(num, 2));
// 120.00
// 绑定事件:delegate
import { On } from '@forgleaner/utils/event';
On(document.body, 'scroll', null, (event) => {
console.log(event.target);
});