GroupCard 群组卡片
展示群组信息的卡片组件,支持操作按钮、信息行与自定义插槽,适用于群列表、群详情等场景。
使用方式
组件以 EmGroupCard 为名导出,全局注册后可直接使用:
vue
<template>
<em-group-card group-id="group_001" name="前端技术交流群" avatar="https://..." />
</template>基础用法
操作与信息行
插槽自定义
弹窗形态 EmGroupCardModal
EmGroupCardModal 是群组卡片的弹窗形态:居中弹窗(320px),打开时自动拉取群详情,渲染群简介与成员数信息行,内置「消息」操作入口。依赖登录态,需在 EmUIKitProvider 内使用。
vue
<script setup lang="ts">
import { ref } from 'vue'
const show = ref(false)
const groupId = 'group_001'
function onSendMessage(id: string) {
// 跳转到该群会话
}
</script>
<template>
<em-group-card-modal
v-model:show="show"
:group-id="groupId"
@send-message="onSendMessage"
/>
</template>GroupCardModal API
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| show | boolean | — | — |
| groupId | string | — | — |
Events
| 事件名 | 参数 | 说明 |
|---|---|---|
update:show | value: boolean | — |
send-message | groupId: string | — |
close | — | — |
send-message触发后会自动关闭弹窗。
API
GroupCard API
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| groupId | string | — | 群 ID |
| name | string | — | 群名称 |
| avatar | string | — | 群头像 URL |
| banner | string | — | 顶部背景图 URL,不传时使用默认渐变 |
| actions | GroupCardAction[] | () => [] | 底部操作按钮 |
| infoRows | GroupCardInfoRow[] | () => [] | 信息行 |
Events
| 事件名 | 参数 | 说明 |
|---|---|---|
action-click | key: string | 点击底部操作按钮时触发,负载为被点击操作的 key(对应 actions 中某一项) |
Slots
| 插槽名 | 说明 |
|---|---|
name | — |
