介绍
showLoading 和 hideLoading
- showLoading :显示 loading 窗
- hideLoading :隐藏 loading 窗
例
this.$u.showLoading('加载页面') // 打开一次 loadingthis.$u.showLoading('你好',1000) // 打开loading 并在 1000毫秒后关闭this.$u.hideLoading() // 关闭一次 loadingthis.$u.hideLoading(true) // 无论有没有loading 没结束,都强制关闭 loading
参数
showLoading
| 参数 | 类型 | 是否必填 | 说明 | | —- | —- | —- | —- | | text | String | N | 提示内容 (默认:加载中) | | time | Number | N | 自动关闭时间(毫秒) | | config | Object | N | 其他配置详情:https://uniapp.dcloud.io/api/ui/prompt?id=showloading |
hideLoading
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| enforce | Boolean | N | 是否强制关闭 |
解决
通过记录调用
showLoading次数,解决多次调用showLoading闪烁问题。showToast 和 hideToast
showToast 提示
- hideToast 隐藏 showToast
例
this.$u.showToast('标题',1000,'none',{}).then(res=>{console.log('弹窗关闭')}this.$u.hideToast(); // 关闭弹窗 并执行弹窗关闭后事件
参数
showToast
| 参数 | 类型 | 是否必填 | 说明 | | —- | —- | —- | —- | | title | String | Y | 提示内容 | | duration | Int | N | 提示的延迟时间,单位毫秒,默认:1500 | | icon | String | N |['success','loading','none']之一 或图片url| | config | Object | N | 其他配置详情:https://uniapp.dcloud.io/api/ui/prompt?id=showtoast |
hideToast
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| can | Boolean | N | 关闭后是否执行 toast 结束事件 |
返回
返回一个
PromiseshowModal:对话框,
- alert:模拟 alert
- confirm: 模拟 confirm
例
```javascript this.$u.showModal({title:’name’}).then(res=>{ console.log(‘确定’) }).catch(res=>{ console.log(‘取消’) })
this.$u.alert(‘name’,’content’).then(res=>{ console.log(‘确定’) })
this.$u.confirm(‘name’,’content’).then(res=>{ console.log(‘点击确定’) },res=>{ console.log(‘点击取消’) })
<a name="a0ACe"></a>#### 参数<a name="wyOhe"></a>##### showModal| 参数 | 类型 | 是否必填 | 说明 || --- | --- | --- | --- || config | Object | Y | 所有配置内容 : [https://uniapp.dcloud.io/api/ui/prompt?id=showmodal](https://uniapp.dcloud.io/api/ui/prompt?id=showmodal) |<a name="M0rkK"></a>##### alert 和 confirm| 参数 | 类型 | 是否必填 | 说明 || --- | --- | --- | --- || title | string | Y | 标题 || content | string | N | 内容 || config | Object | N | 所有配置内容 : [https://uniapp.dcloud.io/api/ui/prompt?id=showmodal](https://uniapp.dcloud.io/api/ui/prompt?id=showmodal) |<a name="YUXKe"></a>#### 返回- 返回一个 `Promise`- `resolve` 点击确定- `reject` 点击取消<a name="0vWqG"></a>### showActionSheet- 从底部向上弹出操作菜单```javascriptthis.$u.showActionSheet(['选项1','选项2','选项3'],'#0000ff').then(res=>{console.log('选择了第'+(res.tapIndex+1))}).catch(res=>{console.log('没选择')})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| itemList | Array | Y | 按钮的文字数组 |
| itemColor | string | N | 按钮的文字颜色,字符串格式,默认为”#000000” |
返回
返回一个
Promiseset : 异步存
- setSync : 同步存
例
```javascript // 普通设置 this.$Storage.set(‘name’,’123’).then(res=>{ console.log(res) })
this.$Storage.setSync(‘Jon’,{age:10,name:’乔恩’}) // 设置数据并设置过期时间
this.$Storage.set(‘name’,’123’,(new Date().getTime())).then(res=>{ console.log(res) })
this.$Storage.setSync(‘Jon’,{age:10,name:’乔恩’},(new Date().getTime()))
<a name="P1nUk"></a>#### 参数| 参数 | 类型 | 是否必填 | 说明 || --- | --- | --- | --- || keyName | String | Y | key || value | | Y | 存储值 || time | Number | N | 过期时间,(毫秒时间戳)仅在使用指定的 `getSync` 取时才游有用 |<a name="vpMu7"></a>### getSync- 同步取<a name="ZVhtt"></a>#### 例```javascriptlet d = this.$Storage.getSync('Jon')
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| keyName | String | Y | key |
