### [微信小程序开发弹出框实现方法](https://www.prosaas.cn/article/17717) **Published:** 2018-03-17T04:05:26 **Author:** 5201314 **Excerpt:** 本文主要和大家分享微信小程序开发弹出框实现方法,本文所分享的代码很清晰,希望能帮助到大家。 1.消息提示——w… 本文主要和大家分享微信小程序开发弹出框实现方法,本文所分享的代码很清晰,希望能帮助到大家。 ![](https://img.php.cn/upload/article/000/054/025/1207429c9edec5cf7e45577e6ac3cdd2-0.png) 1.消息提示——wx.showToast(OBJECT) ### ![](https://img.php.cn/upload/article/000/054/025/1207429c9edec5cf7e45577e6ac3cdd2-1.png) //show.js //获取应用实例 var app = getApp() Page({ showok:function() { wx.showToast({ title: '成功', icon: 'success', duration: 2000 }) } }) ![](https://img.php.cn/upload/article/000/054/025/1207429c9edec5cf7e45577e6ac3cdd2-2.png) 2.模态弹窗——wx.showModal(OBJECT) ![](https://img.php.cn/upload/article/000/054/025/1207429c9edec5cf7e45577e6ac3cdd2-3.png) //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('用户点击取消') } } }) } }) ![](https://img.php.cn/upload/article/000/054/025/1207429c9edec5cf7e45577e6ac3cdd2-4.png) 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) } }) } }) ![](https://img.php.cn/upload/article/000/054/025/0543a4f51993e3418f85610f27bb48f1-6.png) 4.指定modal弹出 ![](https://img.php.cn/upload/article/000/054/025/0543a4f51993e3418f85610f27bb48f1-7.png) 指定哪个modal,可以通过hidden属性来进行选择。 //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 }) } }) ![](https://img.php.cn/upload/article/000/054/025/0543a4f51993e3418f85610f27bb48f1-8.png) 相关推荐: 如何用JQuery写出登录弹出框 推荐10款实现弹出框特效(收藏) 分享HTML5实现弹出框的效果示例 以上就是微信小程序开发弹出框实现方法的详细内容,更多请关注知企PROSAAS其它相关文章! **Categories:** 后端开发 ---