Toast
Examples
Statuses
Toast
has four statuses: info
, success
, warning
, and error
. You can specify different statuses by using the status
prop.
Press any key to continue...
Your profile has been updated.
v1 is deprecated. Use v2 instead.
Uncaught SyntaxError: Unexpected token +
<template>
<article>
<section>
<veui-toast
class="toast"
status="info"
open
message="Press any key to continue..."
/>
</section>
<section>
<veui-toast
class="toast"
status="success"
open
message="Your profile has been updated."
/>
</section>
<section>
<veui-toast
class="toast"
status="warning"
open
>
v1 is deprecated. Use v2 instead.
</veui-toast>
</section>
<section>
<veui-toast
class="toast"
status="error"
open
message="Uncaught SyntaxError: Unexpected token +"
/>
</section>
</article>
</template>
<script>
import { Toast } from 'veui'
export default {
components: {
'veui-toast': Toast
}
}
</script>
<style lang="less" scoped>
.toast {
position: relative;
}
section {
margin-bottom: 20px;
}
</style>
Imperative call
You can use the veui/plugins/toast
module to load the toast
plugin for an imperative call.
<template>
<article>
<veui-button
class="button"
@click="$toast.info({
message: 'Press any key to continue...',
duration: 5000
})"
>
Info
</veui-button>
<veui-button
class="button"
@click="$toast.success('Your profile has been updated.')"
>
Success
</veui-button>
<veui-button
class="button"
@click="$toast.warn('v1 is deprecated. Use v2 instead.')"
>
Warn
</veui-button>
<veui-button
class="button"
@click="$toast.error('Uncaught SyntaxError: Unexpected token +')"
>
Error
</veui-button>
</article>
</template>
<script>
import Vue from 'vue'
import { Button } from 'veui'
import toast from 'veui/plugins/toast'
Vue.use(toast)
export default {
components: {
'veui-button': Button
}
}
</script>
<style lang="less" scoped>
.button {
margin-right: 20px;
}
</style>
API
Props
Name | Type | Default | Description |
---|
open | boolean | false | Whether to display the toast. |
status | string | 'success' | The status of the toast. Value | Description |
---|
info | Information prompt style. | success | Success style. | warning | Warning style. | error | Error style. |
|
type | string | 'success' | Deprecated. Use status instead. |
title | string | - | The message title. |
message | string | - | The message content. |
duration | number | toast.duration | The duration in milliseconds that the message is displayed. If exceeded, the toast will automatically close. |
closable | boolean | - | Whether there is a close button. |
Slots
Name | Description |
---|
default | The content area. Displays the content of the message prop by default. |
title | The title area. Displays the content of the title prop by default. |
Events
Name | Description |
---|
close | Triggered after the toast is automatically closed. |
ready | Triggered after the component is mounted. |
Configs
Key | Type | Default | Description |
---|
toast.duration | number | 3000 | The default duration in milliseconds that the message is displayed. |
Icons