Alert 警告提示
用于页面顶部或局部的静态警告、信息提醒与异常状态通知控件,支持 info / success / warning / error 四大主题语义与 glass (毛玻璃) / filled (实色填充) / plain (简洁) 变体。
代码示例
1. 基础提示 (Basic Usage)
vue
<template>
<mu-alert title="系统通知" description="项目已成功编译并发布至生产环境。" type="success" />
</template>2. 变体与关闭按钮 (Variants & Closable)
vue
<template>
<mu-alert
title="请注意"
description="账户余额不足,请及时充值。"
type="warning"
variant="filled"
closable
@close="onClose"
/>
</template>
<script setup>
function onClose() {
console.log('警告提示已被用户手动关闭')
}
</script>API 属性说明 (Props)
| 参数名 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|
| type | 警告类型与语义主题 | String | info | success | warning | error | 'info' |
| variant | 外观形态变体 | String | glass | filled | plain | 'glass' |
| title | 警告大标题 | String | - | '' |
| description | 详细描述文案 | String | - | '' |
| icon | 自定义前置矢量图标名称 | String | - | '' |
| showIcon | 是否显示前置图标 | Boolean | true | false | true |
| closable | 是否显示右侧关闭图标按钮 | Boolean | true | false | false |
| margin | 外边距(CSS margin 语法) | String | - | '' |
| round | 是否开启圆角样式 | Boolean | true | false | false |
事件说明 (Events)
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| close | 点击关闭图标关闭时触发 | - |
插槽说明 (Slots)
| 插槽名 | 说明 |
|---|---|
| default | 自定义描述内容 Body 插槽 |
| icon | 自定义前置图标插槽 |