Skip to content

XSender Input

使用import { XSender } from 'vue-element-plus-x'
文档
Edit this pageChangelogFeedback

Introduction ​

XSender is a component with built-in smart conversation features including input, tag selection, command popup, user mention, and other scenarios.

📌 Warning

The plugin version must be greater than 1.3.98. The previous version was named EditorSender, and there are significant API differences. Please take note.

Code Examples ​

Basic Usage ​

这是一个XSender 输入框,最简单的使用例子。

Placeholder ​

可以通过 placeholder 设置输入框的提示语。

Auto Focus ​

可以通过 auto-focus 设置输入框自动聚焦。

Status ​

可以通过简单属性是,实现组件的状态

💌 Info

  • 通过 loading 属性,可以控制输入框是否加载中。
  • 通过 disabled 属性,可以控制输入框是否禁用。
  • 通过 clearable 属性,可以控制输入框是否出现删除按钮,实现清空。

Submit Type ​

可以通过 submitType 设置输入框的提交方式。

Layout Variant ​

通过 variant 属性设置输入框的变体。默认 'default' | 上下结构 'updown'

这个属性,将左右结构的 输入框,变成 上下结构的 输入框。上面为 输入框,下面为 内置的 前缀和操作列表栏

Custom Action List ​

通过 #action-list 插槽用于自定义输入框的操作列表内容。

💌 Info

当你使用 #action-list 插槽时,会隐藏内置的输入框的操作按钮。你可以通过和 组件实例方法 相结合,实现更丰富的操作。

Custom Prefix ​

通过 #prefix 插槽用于自定义输入框的前缀内容。

Custom Header ​

💯 欢迎使用 Element Plus X
🦜 自定义头部内容

通过 #header 插槽用于自定义输入框的头部内容,还可以通过 headerAnimationTimer 属性设置头部动画时间。

Custom Input Style ​

通过 customStyle 方便对输入框的样式透传,你可以设置 maxHeight 来限制输入框的高度。这样实现在一定的高度下出现滚动条。

Max Length ​

当前输入长度: / 200

可以通过 maxLength 来限制输入框的最大输入长度。

💔 Danger

该配置项性能开销较大 非必要情况请别设置(像豆包和文心一言都不对这块做限制不应因小失大)

Advanced Usage ​

Input ​

Use setInput to insert an input field for preset values. Use setChatNode to preset template content for the input.

Tag Selection ​

Use setSelect to insert a select picker and preset a value. Use showSelect to open the picker dialog anchored to a target element. Use setChatNode to preset the input content template.

User Mention ​

默认可以通过 @ 触发提及用户选择弹窗。 可以通过 setMention 插入一个提及用户标签。 使用 setChatNode 可以预设输入框内容(如文案、提及等)。

Command Trigger ​

默认可以通过自定义设置触发符触发选择弹窗。 可以通过 setTrigger 插入一个指令标签。 使用 setChatNode 可以预设输入框内容(如文案、指令等)。

Prefix Tip ​

前置标签状态:

可以通过 showTip 唤起前置提示词。 使用 closeTip 可以关闭前置提示词。

Properties ​

Props ​

PropertyTypeRequiredDefaultDescription
placeholderstringfalse请输入内容Placeholder text
devicePC | H5 | autofalseautoInteraction device
autoFocusbooleanfalsefalseAuto focus after render
variantdefault | updownfalsedefaultLayout variant
maxLengthnumberfalse-1Input length limit
submitTypeenter | shiftEnterfalseenterSubmit type
customStyleCSSStyleDeclarationfalse{}Custom input style
loadingbooleanfalsefalseLoading state
disabledbooleanfalsefalseDisabled state
clearablebooleanfalsefalseShow clear button
headerAnimationTimernumberfalse300Header animation duration
mentionConfigMentionConfigfalsenullUser mention config
triggerConfigTriggerConfig[]falsenullCommand popup config
selectConfigSelectConfig[]falsenullTag selection config
tipConfigTipConfig | booleanfalsetruePrefix tip config (true enables defaults, false disables, object enables with custom options)
getPlugin() => typeof XSenderfalsenullCustom underlying plugin version

tipConfig is passed through to the underlying x-sender plugin as-is. This component does not merge defaults on its own: booleans act as an on/off switch, and an object provides custom options.

MentionConfig ​

PropertyTypeRequiredDefaultDescription
dialogTitlestringtrue''Mention popup title
options<{ id: string, name: string, avatar?: string }>[]true[]Data options
callEverybooleanfalsefalseEnable "mention all" option
everyTextstringfalse所有人"Mention all" option text
asyncMatch(matchStr: string) => Promise<MentionItem[]>falsenullEnable async matching mode
emptyTextstringfalse暂无数据Empty result text

TriggerConfig ​

PropertyTypeRequiredDefaultDescription
dialogTitlestringtrue''Command popup title
keystringtruenullTrigger key for command selection
options<{ id: string, name: string }>[]true[]Data options

SelectConfig ​

PropertyTypeRequiredDefaultDescription
dialogTitlestringtrue''Tag selection popup title
keystringtruenullTag selection identifier
options<{ id: string, name: string, preview?: string }>[]true[]Data options
multiplebooleanfalsefalseEnable multiple selection
emptyTextstringfalse暂无数据Empty result text
showSearchbooleanfalsefalseEnable search function
placeholderstringfalse输入关键字查询Search placeholder
searchEmptyTextstringfalse暂无数据Empty search result text

TipConfig ​

PropertyTypeRequiredDefaultDescription
tipTemplatestringfalse''Prefix tip template
dialogTemplatestringfalse''Command popup template
closeNamesstring[]false[]Key list to close popup
offsetTopnumberfalse0Popup top offset