官网文档链接:交互反馈
共用的wxml:
<button type="primary" bindtap="showToastView">showToast</button>
<button type="primary" bindtap="showLoadingView">showLoading</button>
<button type="primary" bindtap="hideToastView">hideToast</button>
<button type="primary" bindtap="hideLoadingView">hideLoading</button>
<button type="primary" bindtap="showModalView">showModal</button>
<button type="primary" bindtap="showActionSheetView">showActionSheet</button>
wx.showToast(OBJECT)
显示消息提示框
showToastView:function(){
wx.showToast({
title: 'showToast',
icon: "success", //图标,有效值 "success", "loading"
image: "/images/index.png", //自定义图标的本地路径,image 的优先级高于 icon,存在版本兼容性
duration: 1500, //提示的延迟时间,单位毫秒,默认:1500
mask: true, //是否显示透明蒙层,防止触摸穿透,默认:false
success: function(){
console.log("success showToast!");
}
})
}
需要注意的就是image可以替代icon的,经测试image目前只支持本地路径
wx.showLoading(OBJECT)
基础库 1.1.0 开始支持,低版本需做兼容处理
显示 loading 提示框, 需主动调用wx.hideLoading才能关闭提示框
showLoadingView: function(){
wx.showLoading({
title: 'showLoading',
mask:true,
success:function(e){
console.log("success showLoading!");
}
})
}