1.3.3 • Published 6 years ago

zsh-tools v1.3.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

一些常用的工具封包

安装

npm install -S zsh-tools

用法
main.js中

import ZSHTOOLS from 'zsh-tools'
import Vue from 'vue'
Vue.use(ZSHTOOLS)

在其他js文件中

import { ws } from 'zsh-tools'

tips:存储的数据建议序列化,取出的数据建议反序列化。

webstore方面

this.$ws.sl('key','value')
//在localstorage中添加键值对key-value
this.$ws.sl('key')
//删掉localstorage中的key字段数据
this.$ws.gl('key')
//查询localstorage中的key数据

// sessionstorage同理
this.$ws.ss('key','value')
this.$ws.ss('key')
this.$ws.gs('key')
//cookie
this.$ws.sc(
  "key", //key
  "xxx", //value
  {//options
    expires: 10, // 有效期为 10 天
    path: "/", // 整个站点有效
    domain: "www.xxx.com", // 有效域名
    secure: true // 加密数据传输
  }
)
this.$ws.gc('user') //查询
this.$ws.dc('key') //删除
this.$ws.gcList() //查询所有,return{key:value,...}

正则

  this.$reg.trim(str)
  this.$reg.checkPhone(str)
  this.$reg.checkIdCode(str)
  // 检测用户姓名
  this.$reg.checkUsername(str)
  this.$reg.checkPassword(str)
  this.$reg.checkBankcard(str)
  // 验证邮箱
  this.$reg.checkEmail(str)
  // 身份证打星号
  this.$reg.hiddenIdcardCode(str)
  // 手机号打星号
  this.$reg.hiddenPhone(str)

时间格式转换器

this.$ts.transCrtTime(date,dateBreak='-',timeBreak=':')
// return {
//   dateTime:`${YYYY}${dateBreak}${MM}${dateBreak}${DD} ${hh}${timeBreak}${mm}${timeBreak}${ss}`,
//   date:`${YYYY}${dateBreak}${MM}${dateBreak}${DD}`,
//   time:`${hh}${timeBreak}${mm}${timeBreak}${ss}`,
//   miniTime:`${hh}${timeBreak}${mm}`
// }
1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.10

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago