textarea

Multi-row entry box.

Attribute NameTypeDefaultDescriptionMinimum Version
nameStringComponent name, used for form submission to get data
valueStringInitial contents
placeholderStringplaceholder
placeholder-styleStringspecify placeholder style
placeholder-classStringspecify placeholder style class
disabledBooleanfalsedisable or not
maxlengthNumber140maximum length, no length limit when setting is -1
focusBooleanfalseget focus
auto-heightBooleanfalseuse auto height or not
show-countBooleantruerender wordcount statistics or not
controlledBooleanfalseIs controlled component or not When it is true, the value content is fulled controlled by setData
onInputEventHandletrigger on keyboard entry, event.detail = {value: value}, can return directly a string to replace the contents in the entry box
onFocusEventHandletrigger on entry box getting focus, event.detail = {value: value}
onBlurEventHandletrigger on entry box losing focus, event.detail = {value: value}
onConfirmEventHandletrigger on clicking completion, event.detail = {value: value}

Screenshot

textarea

Sample Code

copy
<view class="section">
  <textarea onBlur="bindTextAreaBlur" auto-height placeholder="Auto height" />
</view>
<view class="section">
  <textarea placeholder="Get focus only when this button is clicked" focus="{{focus}}" />
  <view class="btn-area">
    <button onTap="bindButtonTap">Have entry box get focus</button>
  </view>
</view>
<view class="section">
  <form onSubmit="bindFormSubmit">
    <textarea placeholder= textarea in the form" name="textarea"/>
    <button form-type="submit"> Submit </button>
  </form>
</view>
copy
Page({
  data: {
    focus: false,
    inputValue: ''
  },
  bindButtonTap() {
    this.setData({
      focus: true
    })
  },
  bindTextAreaBlur: function(e) {
    console.log(e.detail.value)
  },
  bindFormSubmit: function(e) {
    console.log(e.detail.value.textarea)
  }
})