微信小程序点击按钮弹出弹窗_微信小程序开发弹出框实现方法

编程知识 更新时间:2023-04-04 01:45:30

本文主要和大家分享微信小程序开发弹出框实现方法,本文所分享的代码很清晰,希望能帮助到大家。

消息提示框

模态弹窗

操作菜单

1.消息提示——wx.showToast(OBJECT)

//show.js

//获取应用实例

var app = getApp()

Page({

showok:function() {

wx.showToast({

title: '成功',

icon: 'success',

duration: 2000

})

}

})

2.模态弹窗——wx.showModal(OBJECT)

//show.js

//获取应用实例

var app = getApp()

Page({

modalcnt:function(){

wx.showModal({

title: '提示',

content: '这是一个模态弹窗',

success: function(res) {

if (res.confirm) {

console.log('用户点击确定')

} else if (res.cancel) {

console.log('用户点击取消')

}

}

})

}

})

3.操作菜单——wx.showActionSheet(OBJECT)

//show.js

//获取应用实例

var app = getApp()

Page({

actioncnt:function(){

wx.showActionSheet({

itemList: ['A', 'B', 'C'],

success: function(res) {

console.log(res.tapIndex)

},

fail: function(res) {

console.log(res.errMsg)

}

})

}

})

4.指定modal弹出

指定哪个modal,可以通过hidden属性来进行选择。

modal有输入框

//show.js

//获取应用实例

var app = getApp()

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

})

}

})

相关推荐:

更多推荐

微信小程序点击按钮弹出弹窗_微信小程序开发弹出框实现方法

本文发布于:2023-04-04 01:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/49a970fde75751ae53ea57ffd333f9ef.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出   程序开发   按钮   程序   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 40560文章数
  • 14阅读数
  • 0评论数