AlertBox
Demos
Types
AlertBox
component has 3 contextual types, which are success
, info
, and
error. Types are specified with the
type` prop.
<template>
<article>
<veui-button @click="successOpen = true">
Success
</veui-button>
<veui-button @click="errorOpen = true">
Error
</veui-button>
<veui-button @click="infoOpen = true">
Info
</veui-button>
<veui-alert-box
type="success"
:open.sync="successOpen"
>
<template slot="title">
Success
</template>
<div>Saved successfully!</div>
</veui-alert-box>
<veui-alert-box
type="error"
:open.sync="errorOpen"
>
<template slot="title"></template>
<div>Not enough disk space!</div>
</veui-alert-box>
<veui-alert-box
type="info"
:open.sync="infoOpen"
>
<template slot="title"></template>
<div>The total available storage is 5MB.</div>
</veui-alert-box>
</article>
</template>
<script>
import AlertBox from 'veui/components/AlertBox'
import Button from 'veui/components/Button'
export default {
components: {
'veui-alert-box': AlertBox,
'veui-button': Button
},
data () {
return {
successOpen: false,
errorOpen: false,
infoOpen: false
}
}
}
</script>
With title
You can customize the title of alert box with the title
prop.
<template>
<article>
<veui-button @click="open1 = true">
<code>title</code> prop
</veui-button>
<veui-button @click="open2 = true">
<code>title</code> slot
</veui-button>
<veui-alert-box
ui="success"
:open.sync="open1"
title="Success"
@ok="ok"
>
<p>Saved successfully!</p>
</veui-alert-box>
<veui-alert-box
ui="success"
:open.sync="open2"
@ok="ok"
>
<template slot="title">
Success <veui-icon
name="info-circle"
class="icon"
/>
</template>
<p>Saved successfully!</p>
</veui-alert-box>
</article>
</template>
<script>
import AlertBox from 'veui/components/AlertBox'
import Button from 'veui/components/Button'
import Icon from 'veui/components/Icon'
import 'veui-theme-one-icons/info-circle'
import toast from 'veui/managers/toast'
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>
API
Props
Name | Type | Default | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
open | boolean | false |
Whether the alert box is displayed. | ||||||||
type | string | 'success' | The contextual type of the alert box.
| ||||||||
title | string | - | The title of the alert box. | ||||||||
overlay-class | string|Array|Object | - | See the overlay-class prop of Overlay . |
Slots
Name | Description |
---|---|
default | The content of the alert box. |
title | The title of the alert box. Will ignore title prop when specified. |
foot | The foot area of the alert box. Displays an “OK” button by default. |
Events
Name | Description |
---|---|
ok | Triggered when the “OK” button is clicked. |
afterclose | Triggered after the box overlay is closed. If leaving transition is provided by the theme, the event will be triggered after the transition completes. |
Icons
Name | Description |
---|---|
info | Information alert. |
success | Success alert. |
error | Error alert. |