微信小程序的提示框 showToast 和 showLoading

用户操作得到即时反馈,这是很好的用户体验,所以我们经常会使用提示框来反馈一些简短信息。提示框显示后,通常自己关闭,对用户的打扰降到最低。下面简单对比一下常用两个显示对话框方式:

showToast 和 showLoading
 
wx.showToast()
wx.showLoading()
参数

title

icon

image

duration

mask

title

mask

关闭方法

设置duration,定时关闭;

使用wx.hideToast()关闭

只能用wx.hideLoading()关闭
icon

success

loading

none

固定显示加载icon

showToast 举例:

wx.showToast({
  title: '成功',
  icon: 'success',
  duration: 2000
})

showLoading 举例:

wx.showLoading({
  title: '加载中',
})

setTimeout(function(){
  wx.hideLoading()
},2000)

这里是微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/api-react.html#wxshowtoastobject

猜你喜欢

转载自blog.csdn.net/henryhu712/article/details/80335351
今日推荐