Skip to content
Title

Input 输入

通过鼠标或键盘输入字符

基础用法

vue
<template #source>
  <b-input v-model="username" placeholder="请输入内容"></b-input>
</template>
<script setup>
import { ref, computed } from 'vue'
const username = ref('')
</script>
展开代码

前后置用法

Http://
.com
vue
<template #source>
<b-input v-model="username"
@blur="handleBlur"
@focus="handleFocus"
placeholder="请输入密码"
:showPassword="true"
:clearable="true">
<template #prepend>Http://</template>
</b-input>

<b-input v-model="username"
@blur="handleBlur"
@focus="handleFocus"
placeholder="请输入密码"
:showPassword="true"
:clearable="true">
<template #append>.com</template>
</b-input>

</template>

<script setup>
  import {ref,computed} from 'vue'
  const username = ref('')
</script>
</script>
展开代码

API

Input 属性

参数说明类型可选项默认值
type类型stringtext,password 和其他原生 input 的 type 值text
v-model绑定值string/number
placeholder输入框占位文本string
clearable是否可清空booleanfalse
show-password是否显示切换密码图标booleanfalse
disabled禁用booleanfalse
readonly原生属性,是否可读booleanfalse

Input 插槽

参数说明
prefix输入框头部分内容
suffix输入框尾部分
prepend输入前置内容
append输入后置内容

Input 事件

事件名称说明
blur在 input 失去焦点时触发
focus在 input 获取焦点时触发
change仅在输入框失去焦点或用户按下回车时触发
input在 input 值改变时时触发
clear在点击由 clearable 属性生成的清空按钮时触发

Released under the MIT License.