Bubble 对话气泡

用于聊天的气泡组件。

基础用法

三种渲染方式,使用 content 属性将文字渲染出,也可以使用defaultcontent插槽来渲染,

你好, 徐尹啊 !
你好,天选打工人
你好,我不好

聊天

如果不搭配打字效果,建议使用插槽形式来渲染

你好, 徐尹啊 !
你好,天选打工人
难过(ಥ﹏ಥ)

位置和头像

通过 avatar 设置自定义头像,通过 placement 设置位置,提供了 start、end 两个选项。

avatar 可以是el-avatar组件任意属性组成的对象或布尔,或者也可以使用avatar插槽来自定义头像

Good morning, how are you?
What a beautiful day!
Hi, good morning, I'm fine!
Thank you!
Use avatar slot

头和尾

通过 headerfooter 属性设置气泡的头部和底部。可以是字符串或者VNode

也可以使用 headerfooter 插槽自定义渲染

字符串渲染
hello world !
模版渲染
hello world !
tsx或者render渲染
hello world !

加载中

通过 loading 属性控制加载状态。

Loading state:

打字效果

通过设置 typing 属性,开启打字效果。更新 content 如果是之前的子集,则会继续输出,否则会重新输出。

E
E💗

自定义渲染

配合 markdown-it 实现自定义渲染内容。

变体

通过 variant 属性设置气泡的样式变体。

可以使用 content 插槽来自定义内容

variant: filled
variant: outlined
variant: shadow
variant: borderless

content slot

形状

通过 shape 属性设置气泡的形状。

shape: default
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.
shape: round
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.
shape: corner
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.
shape: arrow
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.

气泡列表

预设样式的气泡列表,支持自动滚动。使用 roles 设置气泡默认属性。

roles会自动合并到items每一项中

Mock user content.
Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content.
Mock user content.

语义化自定义

示例通过语义化以及加载定制,来调整气泡效果。

使用loadingRender函数来自定义loading内容,也支持loading 插槽来自定义

M
Mock user content.
Custom loading...

自定义列表内容

自定义气泡列表内容,这对于个性化定制场景非常有用。

当使用messageRender 函数自定义渲染内容时,会把content属性值作为参数传入

N
VNode message
excel-file.xlsx
word-file.docx

API

Bubble 属性

属性名说明类型默认值
variant气泡样式变体enumfilled
avatar头像展示VNode | string | boolean-
loading加载中booleanfalse
typing打字配置boolean | TypingOption-
placement位置enum-
message-render自定义内容渲染(content: any) => VNode | string-
shape形状enum-
content内容string-
header头部内容string | VNode-
footer底部内容string | VNode-
loading-render自定义渲染 loading() => VNode-
on-typing-complete打字效果完成时的回调,如果没有设置 typing 将在渲染时立刻触发() => void-
header-class头部内容 class 名string-
header-style头部内容 stylestring | object | array-
content-class内容 class 名string-
content-style内容 stylestring | object | array-
footer-class底部内容 class 名string-
footer-style底部内容 stylestring | object | array-

Bubble Slots

插槽名说明类型
avatar自定义头像-
header自定义内容头部-
footer自定义内容底部-
content自定义内容(和默认插槽功能一致,优先级 default>content)-
loading自定义 loading-

BubbleList 属性

属性名说明类型默认值
auto-scroll列表是否自动滚动booleantrue
items列表项数据BubbleDataType[]-
roles设置气泡默认属性,items 中的 role 会进行自动对应RolesType | Function-
on-last-bubble-typing-complete最后一项数据打字完成后的回调(key: string | number) => void-

源代码

组件样式文档

贡献者