Modal

Dialog box.

Attribute NameDescriptionTypeDefault
classNameCustom classString
showShow modal or notBooleanfalse
showCloseTurn off render or notBooleantrue
closeTypeClose chart type 0: gray icon 1: white iconString0
onModalClickCallback on clicking footer() => void
onModalCloseCallback on clicking close, not required when showClose is false() => void
topImageTop imageString
topImageSizeTop image rule, options including lg, md and smStringmd
adviceIs operation popup or notBooleanfalse

Slots

slotNameDescription
headerOptional, modal header
footerOptional, modal footer

Example

copy
{
  "defaultTitle": "AntUI Component Library",
  "usingComponents": {
    "modal": "mini-antui/es/modal/index"
  }
}
copy
<view>
  <button onTap="openModal">Show Modal</button>
  <modal
    show="{{modalOpened}}"
    onModalClick="onModalClick"
    onModalClose="onModalClose"
    topImage="https://gw.alipayobjects.com/zos/rmsportal/yFeFExbGpDxvDYnKHcrs.png"
  >
    <view slot="header">Title</view>
    Explain the current status, prompt the user solution, preferably no more than two lines
    <view slot="footer">Confirm</view>
  </modal>
</view>
copy
Page({
  data: {
    modalOpened: false,
  },
  openModal() {
    this.setData({
      modalOpened: true,
    });
  },
  onModalClick() {
    this.setData({
      modalOpened: false,
    });
  },
  onModalClose() {
    this.setData({
      modalOpened: false,
    });
  }
});