# textarea
Start from base library version 1.0.0. Please remaining backward compatible.
Multiline input box. This component is Native component, please note the limitations.
attribute | type | Default value | Required | Introductions | Minimum version |
---|---|---|---|---|---|
value | string | no | Enter the contents of the box | 1.0.0 | |
placeholder | string | no | Placeholder when input box is empty | 1.0.0 | |
placeholder-style | string | no | Designation placeholder Currently supports only color, font-size, and font-weight | 1.0.0 | |
placeholder-class | string | textarea-placeholder | no | Designation placeholder Style class | 1.0.0 |
disabled | boolean | false | no | Is it disabled? | 1.0.0 |
maxlength | number | 140 | no | Maximum input length, set to -1 Does not limit the maximum length | 1.0.0 |
auto-focus | boolean | false | no | Autofocus, pull up the keyboard. | 1.0.0 |
focus | boolean | false | no | Getting focus | 1.0.0 |
auto-height | boolean | false | no | Whether to automatically raise, setting auto-height when style.height does not take effect | 1.0.0 |
fixed | boolean | false | no | if textarea It was in a place position:fixed The specified property needs to be displayed fixed for true | 1.0.0 |
cursor-spacing | number | 0 | no | Specifies the distance between the cursor and the keyboard. taketextarea The distance from the bottom andcursor-spacing The minimum distance specified as the distance between the cursor and the keyboard | 1.0.0 |
cursor | number | -1 | no | Specifies the cursor position when focusing | 1.5.0 |
show-confirm-bar | boolean | true | no | Display the bar above the keyboard with the "Finish" on | 1.6.0 |
selection-start | number | -1 | no | Cursor starting position, valid for automatic aggregation, with theselection-end Collocation use | 1.9.0 |
selection-end | number | -1 | no | Cursor end position, valid for automatic aggregation, with theselection-start Collocation use | 1.9.0 |
adjust-position | boolean | true | no | Does the page automatically push up when the keyboard bounces up | 1.9.90 |
hold-keyboard | boolean | false | no | Does not close the keyboard when you click on the page | 2.8.2 |
disable-default-padding | boolean | false | no | Whether to remove iOS Default inside margin under | 2.10.0 |
confirm-type | string | return | no | Set the text of the on at the bottom right of the keyboard | 2.13.0 |
confirm-hold | boolean | false | no | Click on the on in the lower right corner of the keyboard to keep the keyboard is not folded | 2.16.0 |
bindfocus | eventhandle | no | Triggered when input box is focused, event.detail = { value, height },height For keyboard height, in the base library 1.9.90 Rise support | 1.0.0 | |
bindblur | eventhandle | no | Triggered when the input box loses focus, event. detail = {value, cursor} | 1.0.0 | |
bindlinechange | eventhandle | no | Called when the number of lines in the input box changes, event. detail = {height: 0, heightRpx: 0, lineCount: 0} | 1.0.0 | |
bindinput | eventhandle | no | When keyboard input, triggers input Event, event.detail = {value, cursor, keyCode},keyCode Is a key value and currently the tool does not support returning keyCode parameters.bindinput The return value of the handler is not reflected in the textarea on | 1.0.0 | |
bindconfirm | eventhandle | no | When the click is complete, trigger confirm Event, event.detail = {value: value} | 1.0.0 | |
bindkeyboardheightchange | eventhandle | no | This event is triggered when the keyboard height changes. = {height: height, duration: duration} | 2.7.0 |
confirm-type Legal value
value | Introductions | Minimum version |
---|---|---|
send | The bottom right on is "send" | |
search | The bottom right on is "Search" | |
next | The bottom right on is "Next" | |
go | The on in the lower right corner is "Go" | |
done | The bottom right on is "Done" | |
return | Bottom right on for "wrap" |
# Bug & Tip
tip
:textarea
ofblur
The event will be later than thetap
Event, if needed in thebutton
Click event acquisitiontextarea
, can be usedform
ofbindsubmit
。tip
: Modifying user input over multiple lines of text is not recommended, sotextarea
ofbindinput
Handler does not reflect the return value to thetextarea
Up.tip
: If the keyboard height changes, the keyboardheightchange event may be triggered multiple times. Developers should ignore the same height valuebug
: WeChat version6.3.30
,textarea
When the list is rendered, the newly addedtextarea
Position miscalculated at autofocus.
# sample code
<view class="section">
<textarea bindblur="bindTextAreaBlur" auto-height Placeholder = "auto high" />
</view>
<view class="section">
<textarea Placeholder = "Placeholder color is red" placeholder-style="color:red" />
</view>
<view class="section">
<textarea Placeholder = "This is an autofocus textarea" auto-focus />
</view>
<view class="section">
<textarea Placeholder = "This only focuses when the on is clicked" focus="{{focus}}" />
<view class="btn-area">
<button bindtap="bindButtonTap">Make the input field focus</button>
</view>
</view>
<view class="section">
<form bindsubmit="bindFormSubmit">
<textarea placeholder="form to hit the target textarea" name="textarea"/>
<button form-type="submit"> submit </button>
</form>
</view>
//textarea.js
Page({
data: {
height: 20,
focus: false
},
bindButtonTap: function() {
this.setData({
focus: true
})
},
bindTextAreaBlur: function(e) {
console.log(e.detail.value)
},
bindFormSubmit: function(e) {
console.log(e.detail.value.textarea)
}
})