2.0.0
Skip to content

Sender 输入框 ​

用于聊天的输入框组件。

何时使用 ​

需要构建一个对话场景下的输入框。

代码演示 ​

智能体输入 ​

基本用法 ​

开关组件 ​

词槽填空 ​

实例方法 ​

提交方式 ​

语音输入 ​

自定义语音输入 ​

自定义后缀按钮 ​

展开面板 ​

快捷指令 ​

引用 ​

自定义底部内容 ​

调整发送按钮样式 ​

黏贴文件 ​

API ​

SenderProps ​

属性说明类型默认值版本
allowSpeech是否允许语音输入boolean | SpeechConfigfalse-
autoSize自适应内容高度boolean | { minRows?: number; maxRows?: number }{ maxRows: 8 }-
classNames样式类名见下--
components自定义组件Record<'input', ComponentType>--
defaultValue输入框默认值string--
disabled是否禁用booleanfalse-
footer底部内容VNode | (oriNode, info: { components }) => VNode | false--
header头部面板VNode | (oriNode, info: { components }) => VNode | false--
loading是否加载中booleanfalse-
prefix前缀内容VNode | (oriNode, info: { components }) => VNode | false--
readOnly是否让输入框只读booleanfalse-
rootClassName根元素样式类string--
slotConfig词槽配置,开启词槽填空模式SlotConfigType[]-2.0
styles语义化定义样式见下--
submitType提交模式enter | shiftEnter | falseenter-
suffix后缀操作按钮区域VNode | (oriNode, info: { components }) => VNode | false-2.0
value(v-model)输入框值string--
onChange输入框值改变的回调(value: string, event?: Event, slotConfig?: SlotConfigType[]) => void--
onCancel点击取消按钮的回调() => void--
onPasteFile黏贴文件的回调(files: FileList) => void--
onSubmit点击发送按钮的回调(message: string, slotConfig?: SlotConfigType[]) => void--
typescript
type SpeechConfig = {
  recording?: boolean;
  onRecordingChange?: (recording: boolean) => void;
};
typescript
type ActionsComponents = {
  SendButton: Component;
  ClearButton: Component;
  LoadingButton: Component;
  SpeechButton: Component;
};
typescript
type SlotConfigType =
  | { type: 'text'; value: string; key?: string }
  | { type: 'input'; key: string; props?: { defaultValue?: string; placeholder?: string } }
  | { type: 'select'; key: string; props?: { defaultValue?: string; options: string[]; placeholder?: string } }
  | { type: 'tag'; key: string; props?: { label: VNode; value?: string } }
  | { type: 'custom'; key: string; props?: Record<string, any>; customRender?: Function; formatResult?: Function };

Sender Slots ​

插槽名说明类型
header头部面板-
prefix前缀内容-
suffix后缀操作按钮区域{ ori: VNode; info: { components: ActionsComponents } }
footer底部内容{ ori: VNode; info: { components: ActionsComponents } }

Sender Ref ​

属性说明类型默认值版本
nativeElement外层容器HTMLDivElement--
inputElement内部输入元素HTMLTextAreaElement | HTMLDivElement-2.0
focus获取焦点(option?) => void--
blur取消焦点() => void--
insert插入内容(value, position?) => void-2.0
clear清空内容() => void-2.0
getValue获取当前值() => { value: string; config: SlotConfigType[] }-2.0

Sender.Header ​

属性说明类型默认值版本
children面板内容VNode--
closable是否可关闭booleantrue-
forceRender强制渲染booleanfalse-
open是否展开boolean--
title标题VNode | string--
onOpenChange展开状态改变的回调(open: boolean) => void--

Sender.Switch ​

属性说明类型默认值版本
checkedChildren选中时显示的内容VNode-2.0
classNames样式类名Record<'root' | 'content' | 'icon' | 'title', string>-2.0
defaultValue默认选中状态boolean-2.0
disabled是否禁用booleanfalse2.0
icon图标VNode-2.0
loading是否加载中booleanfalse2.0
onChange切换回调(checked: boolean) => void-2.0
styles语义化定义样式Record<'root' | 'content' | 'icon' | 'title', CSSProperties>-2.0
unCheckedChildren未选中时显示的内容VNode-2.0
value选中状态boolean-2.0

Semantic DOM ​

  • root
    根节点
  • prefix
    前缀
  • input
    输入框
  • suffix
    后缀
  • footer
    底部
  • switch
    开关
  • content
    内容
Header
Content
  • header
    头部
  • content
    头部-内容

主题变量(Design Token) ​

Token说明类型默认值
colorBgSlot词槽背景颜色stringrgba(colorPrimary, 0.06)
colorTextSlot词槽文本颜色stringcolorPrimary
colorTextSlotPlaceholder词槽文本占位符颜色stringrgba(colorPrimary, 0.25)
colorBorderSlot词槽边框颜色stringrgba(colorPrimary, 0.06)
colorBorderSlotHover词槽边框悬浮态颜色stringrgba(colorPrimary, 0.1)
switchCheckedBg开关选中背景颜色stringrgba(colorPrimary, 0.08)
switchCheckedHoverBg开关选中悬浮态背景颜色stringrgba(colorPrimary, 0.1)
switchUncheckedHoverBg开关未选中悬浮态背景颜色stringrgba(colorFillTertiary, 0.04)
colorBorderInput输入框边框颜色stringrgba(colorFillTertiary, 0.1)
colorBgSkill技能背景颜色stringrgba(colorPrimary, 0.08)
colorBgSkillHover技能悬浮态背景颜色stringrgba(colorPrimary, 0.15)

React 文档中的 colorBgActionsDisabled / colorTextActionsDisabled 尚未在 Vue Sender ComponentToken 中暴露,故未收录。