Skip to content

Input组件

<template>
  <open-input v-model="input" style="width: 240px" placeholder="Please input" />
</template>

<script setup lang="ts">
import OpenInput from '@open-design/components/input';
import { ref } from 'vue';

const input = ref('');
</script>

API

Input Attributes

NameDescriptionTypeDefault
typeinput 原生类型'string'text
model-value / v-model绑定值'string'
disabled是否禁用booleanfalse
placeholder输入框占位文本string
size输入框尺寸,只在 type 不为 'textarea' 时有效'large' |'small'
placeholder输入框占位文本string
show-password是否显示切换密码图标booleanfalse
clearable是否显示清除按钮booleanfalse
readonly原生 readonly 属性,是否只读booleanfalse
autofocus原生属性,自动获取焦点booleanfalse
autocomplete原生 autocomplete 属性stringoff

Input Events

NameDescriptionType
blur当选择器的输入框失去焦点时触发(e: FocusEvent) => void
focus当选择器的输入框获得焦点时触发(e: FocusEvent) => void
change当选择器的输入框失去焦点时触发(e: string) => void
input当选择器的输入框获得焦点时触发(e: string) => void
clear在点击由 clearable 属性生成的清空按钮时触发()=>void

Slots

NameDescription
prefix输入框头部内容
suffix输入框尾部内容
prepend输入框前置内容
append输入框后置内容

Exposes

NameDescriptionType
refHTML元素 input 或 textareaRef<HTMLInputElement |HTMLTextAreaElement>