小編給大家分享一下如何使用微信小程序開發(fā)彈出框,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
view class="container" class="zn-uploadimg"> <button type="primary"bindtap="showok">消息提示框</button> <button type="primary"bindtap="modalcnt">模態(tài)彈窗</button> <button type="primary"bindtap="actioncnt">操作菜單</button> </view>
1.消息提示——wx.showToast(OBJECT)
//show.js //獲取應用實例 var app = getApp() Page({ showok:function() { wx.showToast({ title: '成功', icon: 'success', duration: 2000 }) } })
2.模態(tài)彈窗——wx.showModal(OBJECT)
//show.js //獲取應用實例 var app = getApp() Page({ showok:function() { wx.showToast({ title: '成功', icon: 'success', duration: 2000 }) } })
//show.js //獲取應用實例 var app = getApp() Page({ modalcnt:function(){ wx.showModal({ title: '提示', content: '這是一個模態(tài)彈窗', 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屬性來進行選擇。
<!--show.wxml--> <view class="container" class="zn-uploadimg"> <button type="primary"bindtap="modalinput"> modal有輸入框 </button> </view> <modal hidden="{{hiddenmodalput}}" title="請輸入驗證碼" confirm-text="提交" cancel-text="重置" bindcancel="cancel" bindconfirm="confirm"> <input type='text'placeholder="請輸入內(nèi)容" auto-focus/> </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 }) } })
以上是“如何使用微信小程序開發(fā)彈出框”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站欄目:如何使用微信小程序開發(fā)彈出框-創(chuàng)新互聯(lián)
本文地址:http://jinyejixie.com/article2/ddsooc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供建站公司、全網(wǎng)營銷推廣、定制網(wǎng)站、App開發(fā)、App設計、網(wǎng)站維護
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)