Skip to content

Alert ​

Statically display blocks for tips or warnings, which can be dynamically dismissed.

Basic Usage ​

Simply insert content using the default slot.

info alert
success alert
warning alert
error alert
<template>
  <div>
    <b-alert>info alert</b-alert>
    <b-alert type="success">success alert</b-alert>
    <b-alert type="warning">warning alert</b-alert>
    <b-alert type="error">error alert</b-alert>
  </div>
</template>

With Description ​

Customize description content by inserting via #desc.

info alert 我是描述Info...
success alert 我是描述Info...
warning alert 我是描述Info...
error alert 我是描述Info...
<template>
  <div>
    <b-alert>
      info alert
      <template #desc>我是描述Info...</template>
    </b-alert>
    <b-alert type="success">
      success alert
      <template #desc>我是描述Info...</template>
    </b-alert>
    <b-alert type="warning">
      warning alert
      <template #desc>我是描述Info...</template>
    </b-alert>
    <b-alert type="error">
      error alert
      <template #desc>我是描述Info...</template>
    </b-alert>
  </div>
</template>

icon ​

Different icons are automatically added based on the type property, or you can customize icons via the slot.

info alert
success alert
warning alert
error alert Custom error description copywriting.
Customicon Customicon描述
<template>
  <div>
    <b-alert show-icon>info alert</b-alert>
    <b-alert type="success" show-icon>success alert</b-alert>
    <b-alert type="warning" show-icon>warning alert</b-alert>
    <b-alert type="error" show-icon>
      error alert
      <template #desc>Custom error description copywriting.</template>
    </b-alert>
    <b-alert show-icon>
      Customicon
      <template #icon>
        <b-icon name="smile"></b-icon>
      </template>
      <template #desc>Customicon描述</template>
    </b-alert>
  </div>
</template>

Can disable ​

Set closable to make the alert dismissible

An info prompt
A success prompt Content of prompt. Content of prompt. Content of prompt. Content of prompt.
Custom closing content No longer prompt
<template>
  <div>
    <b-alert closable>An info prompt</b-alert>
    <b-alert type="success" show-icon closable>
      A success prompt
      <template #desc>
        Content of prompt. Content of prompt. Content of prompt. Content of prompt.
      </template>
    </b-alert>
    <b-alert type="warning" closable>
      Custom closing content
      <template #close>No longer prompt</template>
    </b-alert>
  </div>
</template>

Top Banner Style ​

Set banner to apply a top banner style.

公告style...
公告style...
<template>
  <div>
    <b-alert banner>公告style...</b-alert>
    <b-alert banner closable type="warning">公告style...</b-alert>
  </div>
</template>

Props ​

ParameterDescriptionTypeOptionsDefault
typeWarningTipstyleStringinfo、success、warning、errorinfo
closableWhether it can be dismissedBoolean—false
show-iconWhether to show iconBoolean—false

Events ​

Event NameDescriptionReturn Value
closeTriggers when dismissedevent

Slot ​

NameDescription
defaultWarning/alert content
descSupplementary description text
iconCustom icon content
closeCustom close content