微信小程序——交互反馈 toast

微信提供了两种方式的交互反馈 toast:

第一种是微信api中的wx.showToast(OBJECT)方法。

具体用法是:wx.showToast({
   title: '成功',
   icon: 'loading',
   duration: 2000
})
title 提示的内容
icon 图标,有效值 "success", "loading"
duration 提示的延迟时间,单位毫秒,默认:1500

出来上述三个参数外还有以下可选参数
image 自定义图标的本地路径,image 的优先级高于 icon
mask 是否显示透明蒙层,防止触摸穿透,默认:false
success 接口调用成功的回调函数
fail 接口调用失败的回调函数
complete 接口调用结束的回调函数(调用成功、失败都会执行)




第二种是wxapp组件形式js控制完成。
具体用法是:

wxml页内容
 <toast hidden="{{toastHidden}}" duration="2000" bindchange="toastChange" icon="warn">
      {{toastmes}}
    </toast>
<button type="default" bindtap="toastTap">点击弹出toast</button>

icon 图标, 有效值:success, success_no_circle, info, warn, waiting, cancel, download, search, clear
duration hidden设置false后,触发bindchange的延时,单位毫秒默认1500
bindchange  duration延迟后 触发

js页内容
    Page({
 data: {
   toastHidden:true,
   toastmes:''
 },
toastTap:function(e){
    this.setData({
 toastHidden:false,
 toastmes:"内容"
  });
}
 toastChange:function(e){
 this.setData({
 toastHidden:true,
  });
  },
  })

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值