這篇文章將為大家詳細(xì)講解有關(guān)微信小程序怎樣自定義對(duì)話框,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
微信小程序 自定義對(duì)話框?qū)嵗斀?/strong>
效果圖:
index.wxml:
請(qǐng)輸入內(nèi)容 取 消 確 定
index.js:
var inputinfo = ""; var app = getApp() Page({ data: { animationData:"", showModalStatus:false }, onLoad: function () { }, showModal: function () { // 顯示遮罩層 var animation = wx.createAnimation({ duration: 200, timingFunction: "linear", delay: 0 }) this.animation = animation animation.translateY(300).step() this.setData({ animationData: animation.export(), showModalStatus: true }) setTimeout(function () { animation.translateY(0).step() this.setData({ animationData: animation.export() }) }.bind(this), 200) }, clickbtn:function(){ if(this.data.showModalStatus){ this.hideModal(); }else{ this.showModal(); } }, hideModal: function () { // 隱藏遮罩層 var animation = wx.createAnimation({ duration: 200, timingFunction: "linear", delay: 0 }) this.animation = animation animation.translateY(300).step() this.setData({ animationData: animation.export(), }) setTimeout(function () { animation.translateY(0).step() this.setData({ animationData: animation.export(), showModalStatus: false }) }.bind(this), 200) }, click_cancel:function(){ console.log("點(diǎn)擊取消"); this.hideModal(); }, click_ok:function(){ console.log("點(diǎn)擊了確定===,輸入的信息為為==",inputinfo); this.hideModal(); }, input_content:function(e){ console.log(e); inputinfo = e.detail.value; } })
關(guān)于“微信小程序怎樣自定義對(duì)話框”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。