1.0.7 • Published 1 year ago

yy-util v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
1 year ago

js常用公共方法

安装

npm install yy-util

import Utils from 'yy-util'

使用

获取url指定参数

let queryString = Utils.getQueryString(name)

获取url所有参数

let query = Utils.getAllQuery()

格式化日期

let date = new Date()

date = Utils.dateFormat('YYYY-mm-dd HH:MM', date)

除去前后,前,后,所有空格

let str = '  te st  '
let type = 1  //type 1-所有空格,2-前后空格,3-前空格,4-后空格

str = Utils.trim(str, type)

判断是否pc端

let isPc = Utils.isPc()

判断是否Ios环境

let isIos = Utils.isIos()

判断是否Android环境

let isAndroid = Utils.isAndroid()

判断是不是微信环境

let isWx = Utils.isWx()

判断是不是全屏手机

let isBigScreen = Utils.isBigScreen()
if (isBigScreen) {
  // 是全屏
} else {
  // 不是
}

防抖

let fun = () => {}
let delay = 500

Utils.debounce(fun, delay)

节流

let fun = () => {}
let delay = 500

Utils.throttle(fun, delay)

获取数据类型

let obj = {}
let type = Utils.getType(obj)

深拷贝

let obj = {}
let copyobj = Utils.copyDeep(obj)

手机号码验证

let number = '18888888888'
let isPhoneNumber = Utils.phoneNumberValid(number)

身份证号码验证

let code = ''
let isIdentityCode = Utils.identityCodeValid(code)
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago