前端常用工具函数集
1.安装对应的函数包
$ npm i @lweb-utils/device --save
2.引入对应函数
ESM:
import { getExplore } from '@lweb-utils/device';
const result = getExplore();
// dosomething...
CommonJS:
const { getExplore } = require('@lweb-utils/device');
const result = getExplore();
// dosomething...
- @lweb-utils/device
- @lweb-utils/dom
- @lweb-utils/storage
- @lweb-utils/string
- @lweb-utils/url
包名 | 安装命令 | 备注 |
---|---|---|
@lweb-utils/device | npm i @lweb-init/device --save | 获取设备信息工具函数 |
@lweb-utils/dom | npm i @lweb-init/dom --save | Dom相关工具函数 |
@lweb-utils/storage | npm i @lweb-init/storage --save | 本地存储工具函数 |
@lweb-utils/string | npm i @lweb-init/string --save | 字符串工具函数 |
@lweb-utils/url | npm i @lweb-init/url --save | Url相关工具函数 |
Device: @lweb-utils/device
- getExplore
- getOS
Dom: @lweb-utils/dom
- hasClass
- addClass
- removeClass
- copyToClipBoard
- addEvent
- removeEvent
- checkPassiveSupport
- loadImg
- loadScript
- ready
- requestWithoutAjax
- scrollTo
- enableScroll
Storage: @lweb-utils/storage
- getCookie,
- setCookie,
- removeCookie,
- getStorage,
- setStorage,
- getLocalStorage,
- getSessionStorage,
- setLocalStorage,
- setSessionStorage,
String: @lweb-utils/string
- fixedZero,
- numberWithCommas,
- percentStr,
- randomStr,
- toCapital,
Url: @lweb-utils/url
- getQueryUrl,
- getUrlParam,
- isUrl,