Skip to content
On this page

input输入框组件 ​

Element Plus 输入框组件文档

Hidden Title ​

基础用法:<s-input v-model="name" />

属性事件插槽简介 ​

基础用法 ​

主题(theme 默认值:default) ​

用示例顶部的选项切换主题,查看普通输入框、带标题输入框、搜索框和多行输入框的外观。基础写法:<s-input v-model="input" :theme="theme" width="320" placeholder="请输入服务名称" />。

size 尺寸 ​

maxlength 最大长度 ​

other ​

禁用状态 ​

一键清空 ​

使用 clearable 属性即可得到一个可一键清空的输入框,s-input 默认值为 true。textarea 始终隐藏 Element Plus 原生清除按钮,只显示 s-input 自定义清除按钮;设置 clearable="false" 后自定义按钮也会隐藏。

格式化 ​

通常用法 ​

复合型输入框 ​

封装el-autocomplete的用法 ​

快捷搜索 search(默认值 false) ​

设置 search 后,搜索按钮显示在输入框内、清空图标右侧。按钮会随输入框的 size 或 height 调整,默认输入框高度仍为 32px。点击搜索按钮或在输入框按 Enter 都会触发 search 事件,参数依次为当前输入值和原始事件。基础写法:<s-input v-model="keyword" search placeholder="搜索工作小组..." @search="handleSearch" />。

上边框标题 top-title(默认值:空字符串) ​

使用 top-title 将标题嵌入输入框上边框,由边框为文字留出缺口,无须额外背景色;原有 title 仍显示在左侧前缀。基础写法:<s-input v-model="maxValue" top-title="X 最大值" width="300" />。

属性 ​

属性名说明类型默认值
modelValue绑定值any-
compTitleStyle标题前缀组件样式;默认内边距为 0 8px,可覆盖object{}
topTitle嵌在输入框上边框的标题,模板中写作 top-titlestring''
width输入框宽度string / number100%
height输入框高度string / number''
maxlength最大输入长度,超出后截断输入并触发 $toast 提示string / number10
hideMaxLengthError是否隐藏超出最大长度时的 $toast 提示booleanfalse
maxLengthErrorText自定义超出最大长度时的 $toast 提示文案string''
size输入框尺寸string''
theme输入框主题stringdefault
showWordLimit是否显示字数统计boolean / stringfalse
block是否按块级宽度展示booleanfalse
disPlaceholder禁用态下显示的占位文案string''
subAttrs外层容器额外属性object{}
tooltipAttrstooltip 额外属性object{}
iconAttrs右侧提示图标属性object{}
hideTooltip是否关闭溢出提示booleanfalse
options自动补全候选项,存在时渲染为 el-autocompletearray-
content右侧说明提示文案string''
search是否在清空图标右侧显示搜索按钮,支持点击或 Enter 搜索booleanfalse
dangerouslyUseHTMLString是否将右侧说明提示的 content 按 HTML 字符串渲染booleanfalse

事件 ​

事件名说明参数
search点击搜索按钮或在输入框按 Enter 时(value, event: MouseEvent / KeyboardEvent)

说明 ​

  • 默认基于 el-input 二次封装,并透传绝大多数 el-input 属性。
  • 当传入 options 时会切换为 el-autocomplete 模式。

思云博智私有前端组件库