微信小程序組件modal

操做反饋modal:官方文檔html

 

Demo Code:ide

Page({
  data: {
    modalHidden: true,
    modalHidden2: true
  },
  modalTap: function(e) {
    this.setData({
      modalHidden: false
    })
  },
  modalChange: function(e) {
    this.setData({
      modalHidden: true
    })
  },
  modalTap2: function(e) {
    this.setData({
      modalHidden2: false
    })
  },
  modalChange2: function(e) {
    this.setData({
      modalHidden2: true
    })
  },
})
JS
<modal title="標題" confirm-text="confirm" cancel-text="cancel" hidden="{{modalHidden}}" bindconfirm="modalChange" 
bindcancel="modalChange" class="modal">
  這是對話框的內容。
</modal>

<modal class="modal" hidden="{{modalHidden2}}" no-cancel bindconfirm="modalChange2">
  <view> 內容能夠插入節點 </view>
</modal>

<view class="btn-area">
  <button type="default" bindtap="modalTap">點擊彈出modal</button>
  <button type="default" bindtap="modalTap2">點擊彈出modal2</button>
</view>
WXML
.modal{
    font-family:"Helvetica Neue","Hiragino Sans GB","Microsoft YaHei","\9ED1\4F53",Arial,sans-serif;
}
.btn-area button{
    margin-top: 10px;
}
WXSS
相關文章
相關標籤/搜索