小程序的模态框和提示框

来源:互联网 发布:北京现代软件学院骗局 编辑:程序博客网 时间:2024/06/07 19:17

一、modal

xml

<!--弹出框--><modal title="退出应用"  hidden="{{hiddenModal}}"  confirm-text="再看看"  cancel-text="退出"  bindconfirm="listenerConfirm"  bindcancel="listenerCancel" >  您是否真的要退出应用  </modal>
js

 listenerButton:function() {  this.setData({   hiddenModal: !this.data.hiddenModal  }) },  listenerConfirm:function() {  this.setData({   hiddenModal: true  }) },  listenerCancel:function() {  this.setData({   hiddenModal: true  }) },

二、wx.showModal(OBJECT)

js

wx.showModal({      title: '提示',      content: '这是一个模态弹窗',      success: function(res) {        if (res.confirm) {        console.log('用户点击确定')        }      }    })



提示框:

wx.showToast(OBJECT)

显示消息提示框

OBJECT参数说明:


示例代码:

?
1
2
3
4
5
wx.showToast({
 title:'成功',
 icon:'success',
 duration: 2000
})

wx.hideToast()

隐藏消息提示框

?
1
2
3
4
5
6
7
8
9
wx.showToast({
 title:'加载中',
 icon:'loading',
 duration: 10000
})
 
setTimeout(function(){
 wx.hideToast()
},2000)

示例代码:

?
1
2
3
4
5
wx.showToast({
 title:'成功',
 icon:'success',
 duration: 2000
})

wx.hideToast()

隐藏消息提示框

?
1
2
3
4
5
6
7
8
9
wx.showToast({
 title:'加载中',
 icon:'loading',
 duration: 10000
})
 
setTimeout(function(){
 wx.hideToast()
},2000)


原创粉丝点击