Textarea 文本域
输入多行文本。
基础用法
通过 rows 设置初始行数。
查看代码收起代码
vue
<script setup lang="ts">
import { ZFormItem, ZTextarea } from '@codex-proxy/ui'
import { ref } from 'vue'
const description = ref('')
</script>
<template>
<ZFormItem label="配置说明">
<ZTextarea v-model="description" :rows="3" placeholder="补充说明" />
</ZFormItem>
</template>自适应高度
设置 autosize 使文本域随内容增高。
查看代码收起代码
vue
<script setup lang="ts">
import { ZTextarea } from '@codex-proxy/ui'
import { ref } from 'vue'
const note = ref('')
</script>
<template>
<ZTextarea v-model="note" aria-label="自适应高度" :autosize="{ minRows: 2, maxRows: 5 }" />
</template>Textarea API
属性
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
validate-event | 随控件事件触发表单校验 | boolean | true |
v-model | 字符串值 | string | '' |
placeholder | 占位文字 | string | '' |
size | 组件尺寸 | 'small' | 'default' | 'large' | 'default' |
rows | 初始行数和 autosize 默认最小行数 | number | 5 |
autosize | 随内容与宽度调整高度 | boolean | { minRows?: number, maxRows?: number } | false |
resize | 拖动方向,autosize 时关闭拖动 | 'none' | 'both' | 'horizontal' | 'vertical' | 'vertical' |
disabled | 禁用输入 | boolean | false |
原生属性与 ARIA 属性传给 textarea,外层接收 class、style。自动填充默认关闭,可用 autocomplete 显式开启。输入法组合完成后更新模型
事件
update:modelValue / input / change(value: string):模型、输入与提交变化focus / blur(event: FocusEvent):焦点变化
实例
focus()、blur()、select()、clear()