微信小程序之----消息提示框toast

toast函数

toast为消息提示框,无按钮,如需关闭弹框能够添加事件设置hidden为true,在弹框显示后通过duration指定的时间后触发bindchange绑定的函数。this

  • 官方文档

  • .wxml
<view>
     <toast hidden="{{hidden}}" duration="2500" bindchange="open" bindtap="close">
        内容
    </toast>
</view>
  • .js
Page({
    data:{
        hidden:false
    },
    open: function(){
        console.log("延时调用");
    },
    close: function(){
        this.setData({
            hidden:true
    });
        console.log("关闭弹框");
    }
})
  • 效果

相关文章
相关标签/搜索