1.0.7 • Published 2 years ago

aver-utils v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

aver-utils

工具类库,只是单纯的把一些常用的方法工具化。

安装依赖

yarn add aver-utils 或 npm install aver-utils

引入依赖

import aver from 'aver-utils';

接口使用

开启或关闭VConsole

此方法主要针对在手机端浏览器上运行的程序,可以设置开启方便查看调试

// 开启VConsole
aver.setConsole({show: true, callback: function() {
  // VConsole show 为 true 时的初始化完成回调
}});

// 关闭VConsole aver.setConsole({show: false, callback: function() { // VConsole show 为 true 时的初始化完成回调 }});

### 获取UUID
```javascript
const UUID = aver.getUUID(); // 195f77c180c23e3f5a8a8f38e4290186

获取浏览器类型

const OStype = aver.getOSType(); // Chrome

获取URL参数

const id = aver.getQueryString("id"); // 获取URL上的id参数

获取设备参数

const device = aver.getDeviceParams(); // {"screenHeight":667,"screenWidth":375,"devicePixelRatio":2}

显示Toast

aver.showToast({
    title: '我是TOAST',
    onHide: function () {
        console.log('Toast加载隐藏了');
    }
})

显示Modal

TODO 待完成

aver.showModal({
    title: '我是标题',
    content: '我是内容',
    closable: true, // 是否可以关闭
    onHide: function () {
        console.log('Modal隐藏了');
    }
})

显示Loading

TODO 待完成

aver.showLoading({
    title: '正在加载',
})

判断字符串是否符合标准

接口可支持-用户名/密码/手机号/身份证/邮箱

// type可传值, phone | password | idcard | username | email
aver.isMatch(type, data);

// 例 aver.isMatch("phone", "13800138000"); // 判断手机格式 aver.isMatch("username", "a12312321"); // 判断用户名,首字母+长度6-20位,字母+数字组合 aver.isMatch("password", "a1231412"); // 判断密码,首字母+长度6-20位,字母+数字组合 aver.isMatch("idcard", "441517745544141251"); // 判断身份证格式 aver.isMatch("email", "aaaa@aaa.com"); // 判断邮箱格式

### 所在环境判断
```javascript
aver.isIOS(); // 是否iOS设备
aver.isAndroid(); // 是否安装设备
aver.isIPhoneX(); // 是否iPhoneX
aver.isIPhoneXR(); // 是否iPhoneXR
aver.isIPhoneXSMax(); // 是否iPhoneXSMax
aver.isMac(); // 是否Mac系统
aver.isWindows(); // 是否Windows系统
aver.isMobile(); // 是否手机
aver.isWeiXin(); // 是否在微信内
aver.isWeiXinMiniProgram(); // 是否在微信小程序内
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago