Skip to content

Textarea 文本域

基础用法

html
<vz-textarea v-model="textareaValue" placeholder="请输入" border></vz-textarea>

禁用状态

html
<vz-textarea v-model="textareaValue" placeholder="不可输入" disabled border></vz-textarea>

只读状态

html
<vz-textarea v-model="textareaValue" placeholder="不可输入" readonly border></vz-textarea>

背景色

html
<vz-textarea
  v-model="textareaValue"
  placeholder="请输入"
  background="var(--vz-color-primary-level-9)"
  border
></vz-textarea>

字数限制

html
<vz-textarea v-model="textareaValue" placeholder="请输入" show-word-limit maxlength="50" border></vz-textarea>

自动增高

html
<vz-textarea v-model="textareaValue" placeholder="请输入" auto-height border></vz-textarea>

下边框

html
<vz-textarea v-model="textareaValue" placeholder="请输入" border-bottom></vz-textarea>

无边框

html
<vz-textarea v-model="textareaValue" placeholder="请输入"></vz-textarea>

Props

属性名说明类型默认值
v-model:model-value绑定的值string / number-
autoFocus自动聚焦,拉起键盘booleanfalse
focus获取焦点booleanfalse
border是否显示边框booleanfalse
border-bottom是否显示下边框booleanfalse
border-color边框颜色string--vz-border-color
background背景string-
maxlength最大输入长度,设置为 -1 的时候不限制最大长度number / string140
show-word-limit是否显示统计字数booleanfalse
interspace内边距string / number20rpx
auto-height是否自动增高booleanfalse
height高度,自动增高时不生效string / number150rpx
min-height最小高度string / number--vz-height-base
max-height最大高度string / number-
placeholder输入框为空时占位符string-
placeholder-class指定 placeholder 的样式类stringinput-placeholder
placeholder-style指定 placeholder 的样式string-
confirm-type设置键盘右下角按钮的文字done / send / search / next / go / returndone
confirm-hold点击键盘右下角按钮时是否保持键盘不收起booleanfalse
cursor-spacing指定光标与键盘的距离number / string0
show-confirm-bar是否显示键盘上方带有“完成”按钮那一栏booleantrue
adjust-position键盘弹起时,是否自动上推页面booleantrue
fixed如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 truebooleanfalse
validate是否触发表单校验booleantrue
i-class根节点样式类string-
i-style根节点样式Vue.StyleValue-

textarea | uniapp

Events

事件名说明参数
input输入时触发model-value
confirm点击键盘完成按钮时触发model-value
focus输入框聚焦时触发-
blur输入框失去焦点时触发-
linechange输入框行数变化时调用-
keyboardheightchange键盘高度发生变化的时候触发此事件-

CSS

变量名说明默认值
--vz-textarea-interspaceprops.interspace20rpx
--vz-textarea-backgroundprops.background-
--vz-textarea-radiusprops.radius--vz-border-radius-base
--vz-textarea-heightprops.height150rpx
--vz-textarea-min-heightprops.minHeight--vz-height-base
--vz-textarea-max-heightprops.maxHeight-
--vz-textarea-border-color边框颜色--vz-border-color
--vz-textarea-counter-size统计字数字体大小--vz-font-size-small
--vz-textarea-counter-color统计字数字体颜色--vz-text-color-thinner
--vz-textarea-disabled-background禁用时背景--vz-bg-color-disabled
--vz-textarea-disabled-color禁用时字体颜色--vz-text-color-disabled

SCSS

scss
$textarea: (
  "interspace": 20rpx,
  "height": 150rpx,
  "min-height": getCssVar("height", "base"),
  "radius": getCssVar("border-radius", "base"),
  "border-color": getCssVar("border-color"),
  "counter-size": getCssVar("font-size", "small"),
  "counter-color": getCssVar("text-color", "thinner"),
  "disabled-background": getCssVar("bg-color", "disabled"),
  "disabled-color": getCssVar("text-color", "disabled"),
);