Skip to content

Input 输入框

通过键盘输入内容的基础表单组件,支持清除、密码显隐切换,并兼容原生输入事件。

基础用法

普通输入值:
密码:
查看代码
vue
<template>
    <div style="display: flex; flex-direction: column; gap: 12px; max-width: 320px">
        <Input v-model="value" placeholder="请输入内容" clearable />
        <Input v-model="pwd" type="password" placeholder="密码" password-toggle />
        <div>普通输入值:{{ value }}</div>
        <div>密码:{{ pwd }}</div>
    </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Input } from "@a-drowned-fish/rox-v";

const value = ref("");
const pwd = ref("");
</script>

Props

参数说明类型默认值
modelValue (v-model)绑定值string | number""
type输入框类型string"text"
placeholder占位文本string""
disabled是否禁用booleanfalse
clearable是否显示清除按钮booleanfalse
passwordToggle是否为密码框并支持显隐切换booleanfalse
name原生 namestring
id原生 idstring
autocomplete原生 autocompletestring
minlength最小长度number
maxlength最大长度number

事件

事件名说明回调参数
update:modelValue输入值变化时触发(value: string) => void
input原生 input 事件(e: Event) => void
change原生 change 事件(e: Event) => void
focus获取焦点(e: FocusEvent) => void
blur失去焦点(e: FocusEvent) => void
clear点击清除按钮() => void
enter按下回车() => void

插槽

插槽名说明
prefix输入框前缀内容
suffix输入框后缀内容

基于 MIT 协议开源