1.消息提示 wx.showToast
wx.showToast({
title: '成功',
icon: 'success',
duration: 2000
})
2.模态弹窗 wx.showModal
wx.showModal({
title: '提示',
content: '这是一个模态弹窗',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
3.操作菜单 wx.showActionSheet
wx.showActionSheet({
itemList: ['A', 'B', 'C'],
success (res) {
console.log(res.tapIndex)
},
fail (res) {
console.log(res.errMsg)
}
})
4.加载中 wx.showLoading
wx.showLoading({
title: '加载中',
})
setTimeout(function () {
wx.hideLoading()
}, 2000)
5.自定义modal(带有表单的弹出框)
<modal hidden="{{hiddenmodalput}}" title="请输入验证码" confirm-text="提交" cancel-text="重置" bindcancel="cancel" bindconfirm="confirm">
<input type='text'placeholder="请输入内容" auto-focus/>
</modal>
- Page({
- data:{
- hiddenmodalput:true,
- //可以通过hidden是否掩藏弹出框的属性,来指定那个弹出框
- },
- //点击按钮痰喘指定的hiddenmodalput弹出框
- modalinput:function(){
- this.setData({
- hiddenmodalput: !this.data.hiddenmodalput
- })
- },
- //取消按钮
- cancel: function(){
- this.setData({
- hiddenmodalput: true
- });
- },
- //确认
- confirm: function(){
- this.setData({
- hiddenmodalput: true
- })
- }
-
- })
注意