VEUI

VEUI on GitHub
Play!中文

Toast

Examples

Statuses

Toast has four statuses: info, success, warning, and error. You can specify different statuses by using the status prop.

Edit this demo on GitHubEdit
<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.

Edit this demo on GitHubEdit
<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

NameTypeDefaultDescription
openbooleanfalse

.sync

Whether to display the toast.

statusstring'success'

The status of the toast.

ValueDescription
infoInformation prompt style.
successSuccess style.
warningWarning style.
errorError style.
typestring'success'Deprecated. Use status instead.
titlestring-The message title.
messagestring-The message content.
durationnumbertoast.durationThe duration in milliseconds that the message is displayed. If exceeded, the toast will automatically close.
closableboolean-Whether there is a close button.

Slots

NameDescription
defaultThe content area. Displays the content of the message prop by default.
titleThe title area. Displays the content of the title prop by default.

Events

NameDescription
closeTriggered after the toast is automatically closed.
readyTriggered after the component is mounted.

Configs

KeyTypeDefaultDescription
toast.durationnumber3000The default duration in milliseconds that the message is displayed.

Icons

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