VEUI

VEUI on GitHub
Play!中文

AlertBox

Examples

Statuses

AlertBox has three statuses: info, success, and error, which can be specified by the status prop.

Edit this demo on GitHubEdit
<template>
<article>
  <veui-button
    class="button"
    @click="successOpen = true"
  >
    Success
  </veui-button>
  <veui-button
    class="button"
    @click="errorOpen = true"
  >
    Error
  </veui-button>
  <veui-button
    class="button"
    @click="infoOpen = true"
  >
    Info
  </veui-button>

  <veui-alert-box
    status="success"
    :open.sync="successOpen"
  >
    <template #title>
      Success
    </template>
    <div>Saved successfully!</div>
  </veui-alert-box>

  <veui-alert-box
    status="error"
    :open.sync="errorOpen"
  >
    <template #title>
      Error
    </template>
    <div>Not enough disk space!</div>
  </veui-alert-box>

  <veui-alert-box
    status="info"
    :open.sync="infoOpen"
  >
    <template #title>
      Sytstem
    </template>
    <div>The total available storage is 5MB.</div>
  </veui-alert-box>
</article>
</template>

<script>
import { AlertBox, Button } from 'veui'

export default {
  components: {
    'veui-alert-box': AlertBox,
    'veui-button': Button
  },
  data () {
    return {
      successOpen: false,
      errorOpen: false,
      infoOpen: false
    }
  }
}
</script>

<style lang="less" scoped>
.button {
  margin-right: 10px;
}
</style>

With title

The title of the alert box can be customized using the title prop or the title slot.

Edit this demo on GitHubEdit
<template>
<article>
  <veui-button
    class="button"
    @click="open1 = true"
  >
    title prop
  </veui-button>
  <veui-button
    class="button"
    @click="open2 = true"
  >
    title slot
  </veui-button>

  <veui-alert-box
    status="success"
    :open.sync="open1"
    title="Success"
    @ok="ok"
  >
    <p>Saved successfully!</p>
  </veui-alert-box>

  <veui-alert-box
    status="success"
    :open.sync="open2"
    @ok="ok"
  >
    <template #title>
      Success
      <veui-icon name="info-circle"/>
    </template>
    <p>Saved successfully!</p>
  </veui-alert-box>
</article>
</template>

<script>
import { AlertBox, Button, Icon, toast } from 'veui'
import 'veui-theme-dls-icons/info-circle'

export default {
  components: {
    'veui-alert-box': AlertBox,
    'veui-button': Button,
    'veui-icon': Icon
  },
  data () {
    return {
      open1: false,
      open2: false
    }
  },
  methods: {
    ok () {
      toast.info('Confirmed')
    }
  }
}
</script>

<style lang="less" scoped>
.button {
  margin-right: 10px;
}
</style>

API

Props

NameTypeDefaultDescription
openbooleanfalse

.sync

Whether to display the alert box.

statusstring'success'

The contextual status of the alert box.

ValueDescription
infoInformational status.
successSuccess status.
errorError status.
typestring'success'Deprecated. Use status instead.
titlestring-The title of the alert box.
loadingbooleanfalseWhether the alert box is in the loading state. When in the loading state, the OK button will also enter the loading state and cannot be clicked.
disabledbooleanfalseWhether the alert box is disabled. When disabled, the OK button will also be disabled and cannot be clicked.
ok-labelstring-The text content of the "OK" button.
before-closefunction(string): boolean=|Promise<boolean>-Executes after the operation that triggers the close, see before-close prop of the Dialog component for reference.
overlay-classstring | Array | Object-See the overlay-class prop of the Overlay component for reference.
overlay-stylestring | Array | Object-See the overlay-style prop of the Overlay component for reference.

Slots

NameDescription
defaultContent area.
titleTitle area. If both the title prop and the title slot are specified, the latter takes precedence.
footFooter area. By default, an “OK” button is displayed.

Events

NameDescription
okTriggered when the “OK” button is clicked.
afteropenTriggered after the alert box is opened. The alert box content is only rendered after opening, so if there is logic that depends on content rendering, execute it after this event is triggered.
aftercloseTriggered after the alert box is closed. If the theme provides an exit animation, it will be triggered after the exit animation is completed.

Icons

NameDescription
infoNormal information.
successSuccess state.
errorError state.
Edit this page on GitHubEdit
© Baidu, Inc. 2024