微信小程序把玩(二十三)modal組件

原文: 微信小程序把玩(二十三)modal組件

這裏寫圖片描述

modal彈出框經常使用在提示一些信息好比:退出應用,清楚緩存,修改資料提交時一些提示等等。javascript

經常使用屬性:java

這裏寫圖片描述

wxmlexpress

<!--監聽button點擊事件--> <button bindtap="listenerButton" type="primary">彈出modal</button> <!--彈出框--> <modal title="退出應用" hidden="{{hiddenModal}}" confirm-text="再看看" cancel-text="退出" bindconfirm="listenerConfirm" bindcancel="listenerCancel" > 您是否真的要退出應用 </modal>

js小程序

Page({
  data:{
    // text:"這是一個頁面"
    hiddenModal: true
  },

  listenerButton:function() {
      this.setData({
          hiddenModal: !this.data.hiddenModal
      })
  },

  listenerConfirm:function() {
      this.setData({
          hiddenModal: true
      })
  },

  listenerCancel:function() {
      this.setData({
          hiddenModal: true
      })
  },

  onLoad:function(options){
    // 頁面初始化 options爲頁面跳轉所帶來的參數
  },
  onReady:function(){
    // 頁面渲染完成
  },
  onShow:function(){
    // 頁面顯示
  },
  onHide:function(){
    // 頁面隱藏
  },
  onUnload:function(){
    // 頁面關閉
  }
})
相關文章
相關標籤/搜索