1.0.18 • Published 3 years ago

zzb-utils v1.0.18

Weekly downloads
1
License
ISC
Repository
-
Last release
3 years ago

zzb-utils

  dist                        - 外部引用资源包
  docs                        - 更新日志
  src                         - 资源文件
  ├── filter                  - 过滤器
  │   ├── formatTime          - 判断是否为空
  │   └── isNullOrEmpty       - 判断字符是否为空
  ├── utils                   - 工具类
  │   ├── base                - 基础方法
  │   │   └── getTypeOf       - 原型链判断数据类型
  │   ├── math                - math计算方法
  │   │   ├── add             - 加法
  │   │   ├── sub             - 减法
  │   │   ├── mul             - 乘法
  │   │   └── div             - 除法
  │   ├── str                 - 字符串常用方法
  │   │   ├── isNullOrEmpty   - 判断字符是否为空
  │   │   ├── trimAll         - 去除所有空格
  │   │   ├── replaceAll      - 替换所有匹配的字符内容
  │   │   ├── replaceBetween  - 替换两边匹配的字符内容
  │   │   ├── replaceLeft     - 替换左边匹配的第一个字符内容
  │   │   └── replaceRight    - 替换右边匹配的第一个字符内容
  │   └── time                - 时间相关操作
  │       └── formatTime      - 时间格式化
  └── validate
      ├── minLength           - 字符串长度不小于length
      ├── maxLength           - 字符串商都不大于length
      ├── phone               - 手机号校验
      ├── tel                 - 固话校验
      ├── email               - 邮箱校验
      ├── idCard              - 身份证校验
      ├── url                 - url校验
      ├── isNumAndLetter      - 判断是否为字母及数字组合
      ├── isNumber            - 判断是否为纯数字
      ├── isLetter            - 判断是否为字母
      ├── isLowerCase         - 判断是否为纯小写字母
      └── isUpperCase         - 判断是否为纯大写字母
//注册filter方法
Object.keys(Utils.filter).map(key => {
  Vue.filter(key, Utils.filter[key])
})

//filter调用(Vue)
{{new Date() | formatTime("YYYY-MM-DD hh:mm:ss")}}

//注册validate方法
Object.keys(Utils.validate).map(key => {
  if (!Vue.prototype.$validate) {
    Vue.prototype.$validate = {}
  }
  Vue.prototype.$validate[key] = Utils.validate[key]
})

//注册utils方法
Object.keys(Utils.utils).map(key => {
  Vue.prototype['$' + key] = Utils.utils[key]
})

//validate及utils调用
console.log(this.$validate.phone("12345678910"))                      //true
console.log(this.$base.getTypeOf("qwe"))                              //string
console.log(this.$str.isNullOrEmpty("qwe"))                           //false
console.log(this.$math.add(1, 2))                                     //3
console.log(this.$time.formatTime(new Date(), "YYYY-MM-DD hh:mm:ss")) //2020-05-19 10:47:22
1.0.18

3 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago