多行文本输入框组件。
起始版本:1.0.0
名称 | 类型 | 默认值 | 必填 | 描述 |
|---|---|---|---|---|
value | string | - | 否 | 输入框的初始内容。 |
confirm-type | string | return | 否 | confirm-type的类型,有效值如下:
|
placeholder | string | - | 否 | 输入框为空时占位符。 |
focus | boolean | false | 否 | 获取焦点。 起始版本:1.0.5 |
placeholder-style | string | - | 否 | 指定 placeholder 的样式,目前仅支持color,font-size和font-weight。 |
disabled | boolean | false | 否 | 是否禁用。 |
maxlength | number | 140 | 否 | 最大输入长度,设置为 -1 的时候不限制最大长度。 |
auto-height | boolean | false | 否 | 是否自动增高,设置auto-height时,style.height不生效。 |
bindinput | eventhandle | - | 否 | 键盘输入时触发,event.detail = {value}。 |
bindfocus | eventhandle | - | 否 | 输入框聚焦时触发。 |
bindblur | eventhandle | - | 否 | 输入框失去焦点时触发。 |
bindconfirm | eventhandle | - | 否 | 点击完成按钮时触发。 |
hxml文件:
<view class="page-section">
<view class="textarea-wrp">
<textarea
bindblur="bindTextAreaBlur"
confirm-type="go"
maxlength="140"
auto-height="{{true}}"
/>
</view>
</view>
<view class="page-section">
<view class="page-section-title">placeholder颜色是红色的</view>
<view class="textarea-wrp">
<textarea
placeholder="placeholder颜色是红色的"
placeholder-style="color:red;font-size:20;font-weight:200"
/>
</view>
</view> js代码:
Page({
data: {
},
bindTextAreaBlur(e) {
console.log(e.detail.value)
},
})