Skip to content

引入组件 ​

局部引入

ts
// parent.vue
const FInput = defineAsyncComponent(() => import('@/components/formaui/f-input/f-input.vue'))

基础用法 ​

通过 v-model 双向绑定输入值

html
<f-input v-model="value" placeholder="请输入内容" />
ts
import { ref } from 'vue'
const value = ref('')

带标题 ​

label 属性:左侧标题文字

html
<f-input v-model="value" label="姓名" placeholder="请输入姓名" show-border-bottom />

必填项 ​

isRequired 属性:显示红色星号(默认 false)

html
<f-input v-model="value" label="手机号" is-required placeholder="请输入手机号" show-border-bottom />

可清除 ​

isClearable 属性:显示清除按钮(默认 false)

html
<f-input v-model="value" placeholder="输入后可清除" is-clearable show-border-bottom />

密码输入 ​

password 属性:密码类型输入(默认 false)

html
<f-input v-model="value" label="密码" password placeholder="请输入密码" show-border-bottom />

插槽 ​

名称说明
left左侧插槽
right右侧插槽

属性 ​

名称类型说明默认值
v-modelstring / number输入值''
labelstring左侧标题''
labelFontSizestring标题字体大小32rpx
labelColorstring标题颜色#0B1D4A
labelWidthstring标题最小宽度140rpx
isRequiredboolean是否必填项false
requiredColorstring必填星号颜色colors.danger 主题
isClearableboolean是否显示清除按钮false
clearSizenumber清除图标大小(px)15
clearColorstring清除图标颜色#bfbfbf
isFocusboolean是否自动聚焦false
placeholderstring占位符''
placeholderStylestring占位符样式-
namestring表单字段名''
typestring与官方 input type 一致text
passwordboolean是否密码类型false
disabledboolean是否禁用false
maxlengthnumber / string最大输入长度140
minnumber / string最小值(number 类型)NaN
maxnumber / string最大值(number 类型)NaN
fontSizestring输入框字号32rpx
textColorstring输入框颜色#0B1D4A
isInputBorderboolean是否显示 input 边框false
borderColorstring边框颜色var(--f-border-color)
isFilletboolean是否胶囊圆角样式false
showBorderTopboolean是否显示上边框false
showBorderBottomboolean是否显示下边框false
isLineLeftboolean下边框是否有左偏移false
isTrimboolean是否自动去除首尾空格true
isTextRightboolean文本是否右对齐false
paddingstring容器内边距26rpx 30rpx
bgColorstring背景颜色#FFFFFF
borderRadiusstring圆角0
marginTopstring上外边距0rpx
cursorSpacingnumber光标与键盘的距离0
confirmTypestring键盘右下角按钮文字类型done
confirmHoldboolean点击完成按钮时是否保持键盘不收起false
cursornumber光标位置-1
selectionStartnumber选区起始位置-1
selectionEndnumber选区结束位置-1
adjustPositionboolean键盘弹起时是否自动上推页面true
holdKeyboardboolean收起键盘时是否保持 focusfalse
autoBlurbooleanfocus 时点击页面是否自动 blurfalse

事件 ​

事件名说明回调参数
focus输入框聚焦时事件对象
blur输入框失焦时事件对象
confirm点击键盘完成时事件对象
click点击容器区域时{ name }
keyboardheightchange键盘高度变化时详情对象

方法 ​

方法名说明传入参数
---