Modal

Dialog box.

Property

DescriptionTypeDefault
classNameCustom class.String
showShow modal or not.Booleanfalse
showCloseTurn off render or not.Booleantrue
closeTypeClose chart type 0: gray icon 1: white icon.String0
onModalClick

Callback on clicking footer.

() => void
onModalCloseCallback on clicking close, not required when showClose is false.() => void
topImageTop image.String
topImageSize

Top image rule, options including lg, md and sm.

Stringmd
adviceIs operation popup or not.Booleanfalse

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://img.example.com/example.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,
    });
  }
});