Skip to content

Conversations 管理对话

用于承载用户侧发送的历史对话列表。

何时使用

  • 需要对多个会话进行管理
  • 查看历史会话列表

代码演示

基本

基础用法。

  • Conversation Item 1
  • Conversation Item 2
  • Conversation Item 3
  • Conversation Item 4
查看源代码

会话操作

配合 menu 属性,配置操作菜单

  • Conversation Item 1
  • Conversation Item 2
  • Conversation Item 3
  • Conversation Item 4
查看源代码

受控模式

使用 activeKeyonChange 属性,控制当前选中的会话

  • Conversation Item 1
  • Conversation Item 2
  • Conversation Item 3
查看源代码

分组展示

使用 groupable 属性开启分组,开启后默认按 Conversation.group 字段分组

    • Conversation Item 1
    • Conversation Item 2
    • Conversation Item 3
    • Conversation Item 4
查看源代码

分组排序

通过 groupable.sort 属性对分组排序, 通过 groupable.title 自定义渲染分组

  • Today
    • Conversation 1732204800000
    • Conversation 1732204803600
    • Conversation 1732204807200
    • Conversation 1732204810800
  • Yesterday
    • Conversation 1732204728000
    • Conversation 1732204731600
查看源代码

API

ConversationsProps

属性说明类型默认值版本
v-model:activeKey当前选中的值string--
defaultActiveKey默认选中值string--
items会话列表数据源Conversation[]--
onActiveChange选中变更回调(value: string) => void--
menu会话操作菜单MenuProps | ((value: Conversation) => MenuProps)--
groupable是否支持分组, 开启后默认按 Conversation.group 字段分组boolean | GroupableProps--
styles语义化结构 styleRecord<'item', CSSProperties>--
classNames语义化结构 classNameRecord<'item', string>--

Bubble Slots

插槽名说明类型
title排序后自定义头部内容-
item自定义label区域内容-
icon自定义icon区域内容-
menu-icon自定义下拉菜单icon区域内容-

Conversation

属性说明类型默认值版本
key唯一标识string--
label会话名称VNode | string--
timestamp会话时间戳number--
group会话分组类型,与 ConversationsProps.groupable 联动string--
icon会话图标VNode | string--
disabled是否禁用boolean--

GroupableProps

属性说明类型默认值版本
sort分组排序函数(a: string, b: string) => number--
title自定义渲染组件((group: string, info: { components: { GroupTitle: typeof GroupTitle } }) => VNode)--