微信小程序中,往往每个小程序中会有一个列表页,首次进入时,加载数据时出现一个加载提示的信息显示,以及加载完成后,要取消这个事件,这样做的目的是为了用户的友好交互,感觉更高大上。
参考链接如下:
https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
wx.showLoading(加载提示显示)
显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
title | string | 是 | 提示的内容 | |
mask | boolean | false | 否 | 是否显示透明蒙层,防止触摸穿透 |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码
// 加载提示显示
wx.showLoading({
title: '数据加载中...',
mask: true
});
取消加载提示
// 隐藏加载提示
wx.hideLoading();
整体示例代码
wx.showLoading({
title: '加载中',
})
setTimeout(function () {
wx.hideLoading()
}, 2000)
网友评论