Giter VIP home page Giter VIP logo

comutils's Introduction

comutils  GitHub forksGitHub stars

npm Build Status LICENSE MIT

前端代码常用工具类

目的:集成前端常用工具类

安装使用

  1. 直接下载bulid目录下的comutils.min.js使用,支持UMD通用模块规范
  <script src="comutils.min.js"></script>
  <script>
      var copyObj = comutils.copyObj(obj1,obj2)
  </script>
  1. 使用npm安装
$ npm install --save-dev comutils

推荐使用方法

不需要完整引入所有函数,只引入需要使用的方法即可

// 只引入部分方法('outils/<方法名>')
const isUrl = require('outils/isUrl')
const isUrl = isUrl()

API文档

Class

  classApi  className的操作api

    classApi.isElement(el) //是否元素节点
    classApi.hasClass(el,cls)
    classApi.addClass(el,cls)
    classApi.removeClass(el,cls)
    classApi.toggleClass(el,cls)

Object

  copyObj  对象合并/深浅拷贝

Regexp

  isEmail  判断是否为邮箱地址

  isIdCard  判断是否为身份证号

  isPhoneNum  判断是否为手机号

  isUrl  判断是否为URL地址

  priceSubstr  千位分割方法

Secret

  secretInfo  给隐私信息标记号加密

Time

  formatPassTime  格式化时间戳为天时分秒[d,h,m,s]

  formatTime  格式化时间戳为年月日时分秒[y-m-d h:m:s]

device

  isWeixin  是否是微信浏览器

  mobileType  设备类型iphone or android

  getOs  是否是手机mobile or web

function

  throttle  节流函数

  debounce  防抖函数

dom

  scrollApi  scrollApi方法

    scrollApi.getScrollTop()
    scrollApi.setScrollTop(h)
    scrollApi.scrollTo(to,duration)

  softKeyCal  移动端端软键盘呼出和消失的事件回调

localStorage

  localStorageApi  本地持久化存储

    localStorageApi.set(name)
    localStorageApi.get(name)
    localStorageApi.remove(name)
    localStorageApi.clear(name)

cookie

  cookieApi  cookie存储(适用和服务端交互)

    cookieApi.set(name, value[, end[, path[, domain[, secure]]]])
    cookieApi.get(name)
    cookieApi.has(name)
    cookieApi.remove(name)
    cookieApi.keys()

Type

  typeOf  判断类型

Url

  getUrlParams  url参数转对象

  stringfyQs  对象序列化

random

  getRandom  返回选定返回的随机整数

collections

  shuffle  数组打乱随机乱序

array

  arrayEqual  判断数组是否相等

animationFrame

  animationFrame  AnimationFrame简单兼容hack

prefixStyle

  prefixStyle  prefixStyle css针对不同浏览器加前缀

comutils's People

Watchers

Seeker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.