常用方法
开发准备
base64 编码
this.$utils.base64.encode(text);
支持版本:V8.8.3
输入参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | 需要编码的字符串 |
返回内容:编码的结果,字符串类型
返回数据样例:
const result = this.$utils.base64.encode('xxx');
base64 解码
this.$utils.base64.decode(text);
支持版本:V8.8.3
输入参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | base64编码字符串 |
返回内容:解码的结果,字符串类型
返回数据样例:
const result = this.$utils.base64.decode(text);
md5
this.$utils.md5(text);
支持版本:V8.8.3
输入参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | 需要编码的字符串 |
返回内容:编码的结果,字符串类型
返回数据样例:
const result = this.$utils.md5('xxx');
生成guid
this.$utils.guid();
支持版本:V8.8.3
输入参数:无
返回内容:guid字符串
返回数据样例:
const result = this.$utils.guid();
比较对象是否相等
this.$utils.compareObjects(obj1, obj2)
支持版本:V8.8.3
输入参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| obj1 | object | 是 | 比较参数1 |
| obj2 | object | 是 | 比较参数2 |
返回内容:
| 参数 | 类型 | 含义 |
|---|---|---|
| result | bool | true表示相等,false表示不相等 |
返回数据样例:
const result = this.$utils.compareObjects({a:1}, {a:2});
Rsa
this.$utils.rsa(text);
支持版本:V8.8.3
输入参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | 需要加密的字符串 |
返回内容:
| 参数 | 类型 | 含义 |
|---|---|---|
| result | string | 加密之后的字符串 |
返回数据样例:
const result = this.$utils.rsa(text);
是否是移动端
this.$utils.isMobile // bool类型的属性
支持版本:V8.8.3
获取IP地址
this.$utils.getIpAddress().then(function (response) {
// 请求成功的回调
console.log(response);
})