Skip to content

文本域 Textarea

多行纯文本编辑控件,适用于评论或反馈表单中的一段意见。

基本使用

可以用于多行输入。


代码事例
vue
<template>
  <fk-textarea placeholder="商品衣诚" allow-clear/>
</template>

文本域状态

文本域可以设置禁用和错误状态。


代码事例
vue
<template>
  <fk-space direction="vertical" size="large" style="width: 100%">
    <fk-textarea placeholder="Disabled status" disabled/>
    <fk-textarea placeholder="Error status" error/>
  </fk-space>
</template>

字数统计

设置 max-length 可以限制最大字数,配合 show-word-limit 可以显示字数统计。


代码事例
vue
<template>
  <fk-space direction="vertical" size="large" fill>
    <fk-textarea placeholder="商品衣诚" :max-length="10" allow-clear show-word-limit />
    <fk-textarea
placeholder="商品衣诚" :max-length="{length:10,errorOnly:true}" allow-clear
                show-word-limit />
  </fk-space>
</template>

自适应高度

通过设置 auto-size,可以让文本框自适应输入内容。


代码事例
vue
<template>
  <fk-textarea default-value="This is the contents of the textarea. This is the contents of the textarea. This is the contents of the textarea." auto-size show-word-limit :max-length="1000" />
  <fk-textarea
default-value="This is the contents of the textarea. This is the contents of the textarea. This is the contents of the textarea." :auto-size="{
    minRows:5,
    maxRows:5
  }" show-word-limit :max-length="1000" style="margin-top: 20px"/>
</template>

API

<textarea> Props

参数名描述类型默认值版本
model-value (v-model)绑定值string-
default-value默认值(非受控状态)string''
placeholder提示文字string-
disabled是否禁用booleanfalse
error是否为错误状态booleanfalse
max-length输入值的最大长度,errorOnly 属性在 1.0.0 版本添加number | { length: number; errorOnly?: boolean }0
show-word-limit是否显示字数统计booleanfalse
allow-clear是否允许清空文本域booleanfalse
auto-size是否让文本框自适应内容高度boolean | AutoSizefalse
word-length字符长度的计算方法(value: string) => number-
word-slice字符截取方法,同 wordLength 一起使用(value: string, maxLength: number) => string-1.0.0

<textarea> Events

事件名描述参数
input用户输入时触发value: string
ev: Event
change仅在文本框失焦时触发value: string
ev: Event
clear点击清除按钮时触发ev: MouseEvent
focus文本框获取焦点时触发ev: FocusEvent
blur文本框失去焦点时触发ev: FocusEvent

<textarea> Methods

方法名描述参数返回值版本
focus使输入框获取焦点--1.0.0
blur使输入框失去焦点--1.0.0

基于 MIT 许可发布