Skip to content

Input 输入框

通过鼠标或键盘输入内容。

基础用法

输入值:
vue
<template>
  <x-input v-model="value" placeholder="请输入内容" />
</template>

<script setup>
import { ref } from 'vue'
const value = ref('')
</script>

禁用状态

vue
<template>
  <x-input v-model="value" disabled placeholder="禁用状态" />
</template>

可清空

使用 clearable 属性即可得到一个可清空的输入框。

vue
<template>
  <x-input v-model="value" clearable placeholder="可清空" />
</template>

密码输入框

使用 show-password 属性即可得到一个可切换显示密码的输入框。

👁️
vue
<template>
  <x-input v-model="password" type="password" show-password placeholder="请输入密码" />
</template>

不同尺寸

vue
<template>
  <x-input size="large" placeholder="大型输入框" />
  <x-input placeholder="默认输入框" />
  <x-input size="small" placeholder="小型输入框" />
</template>

API

Props

属性说明类型默认值
modelValue绑定值string | number
type类型'text' | 'password' | 'email' | 'number' | 'tel' | 'url''text'
placeholder输入框占位文本string
size输入框尺寸'large' | 'default' | 'small''default'
disabled是否禁用booleanfalse
readonly是否只读booleanfalse
maxlength最大输入长度number
clearable是否可清空booleanfalse
showPassword是否显示切换密码图标booleanfalse
showWordLimit是否显示字数统计booleanfalse

Events

事件名说明回调参数
update:modelValue输入值改变时触发(value: string)
input输入时触发(value: string)
change值改变时触发(value: string)
focus获得焦点时触发(event: FocusEvent)
blur失去焦点时触发(event: FocusEvent)
clear清空时触发

基于 MIT 许可发布