Message 消息 #
基本使用 #
基本使用
调用`Message`函数进行消息提示
<template>
  <div class="everyMargin">
    <h-button @click="showMessage('info', '普通消息')" type="primary">普通消息</h-button>
    <h-button @click="showMessage('success', '成功消息')" type="info">成功消息</h-button>
    <h-button @click="showMessage('warning', '警告消息')" type="warning">警告消息</h-button>
    <h-button @click="showMessage('danger', '危险消息')" type="error">危险消息</h-button>
  </div>
</template>
<script lang="ts" setup>
import { Message } from '@hare-ui/hare-ui'
function showMessage(type, message) {
  Message({
    center: true,
    type,
    message
  })
}
</script>
<style scoped lang="scss">
.everyMargin *{
  margin: 0 2px;
}
</style>
组件 API #
Message 配置项 #
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 
|---|---|---|---|---|
| message | 消息内容 | string | - | - | 
| type | 消息类型 | string | info/success/warning/danger | info | 
| duration | 消息持续毫秒数 | number | - | 2000 | 
| center | 消息是否居中 | boolean | - | true | 
| onClose | 消息消失是的回调函数 | function | - | - | 
hare-ui