


Form Component_Detailed explanation of mini program form multi-line input box table
Multi-line input box.
Attribute name | type | default value | illustrate |
---|---|---|---|
value | String | Contents of the input box | |
placeholder | String | Placeholder when the input box is empty | |
placeholder-style | String | Specify the style of placeholder | |
placeholder-class | String | textarea-placeholder | Specify the style class of placeholder |
disabled | Boolean | false | Whether to disable |
maxlength | Number | 140 | Maximum input length, when set to -1, there is no limit to the maximum length |
auto-focus | Boolean | false | Auto focus, pull up the keyboard. |
focus | Boolean | false | Get focus |
auto-height | Boolean | false | Whether to automatically increase the height. When setting auto-height, style.height does not take effect |
fixed | Boolean | false | If the textarea is in a position:fixed area, the specified attribute fixed needs to be displayed as true |
cursor-spacing | Number | 0 | Specify the distance between the cursor and the keyboard, in px. Take the minimum value of the distance between the textarea and the bottom and the distance specified by cursor-spacing as the distance between the cursor and the keyboard |
bindfocus | EventHandle | Triggered when the input box is focused, event.detail = {value: value} | |
bindblur | EventHandle | Triggered when the input box loses focus, event.detail = {value: value} | |
bindlinechange | EventHandle | Called when the number of lines in the input box changes, event.detail = {height: 0, heightRpx: 0, lineCount: 0} | |
bindinput | EventHandle | When keyboard input occurs, the input event is triggered, event.detail = {value: value}, The return value of the bindinput processing function will not be reflected on the textarea | |
bindconfirm | EventHandle | When the click is completed, the confirm event is triggered, event.detail = {value: value} |
Sample code:
<!--textarea.wxml--> <view class="section"> <textarea bindblur="bindTextAreaBlur" auto-height placeholder="自动变高" /> </view> <view class="section"> <textarea placeholder="placeholder颜色是红色的" placeholder-style="color:red;" /> </view> <view class="section"> <textarea placeholder="这是一个可以自动聚焦的textarea" auto-focus /> </view> <view class="section"> <textarea placeholder="这个只有在按钮点击的时候才聚焦" focus="{{focus}}" /> <view class="btn-area"> <button bindtap="bindButtonTap">使得输入框获取焦点</button> </view> </view><view class="section"> <form bindsubmit="bindFormSubmit"> <textarea placeholder="form 中的 textarea" name="textarea"/> <button form-type="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) } })
Bug & Tip
bug
: In WeChat version6.3.30
, whentextarea
is rendered in the list, the position of the newly addedtextarea
during automatic focus is calculated incorrectly.tip
:textarea
’sblur
event will be later than thetap
event on the page , if you need to gettextarea
in the click event ofbutton
, you can usebindsubmit
ofform
.tip
: It is not recommended to modify user input on multi-line text, sobindinput
oftextarea
The processing function does not reflect the return value totextarea
.tip
:textarea
component is a native component created by the client, and its level is the highest.tip
: Do not use thetextarea
component inscroll-view
.tip
:css
animation is not valid for thetextarea
component.
Related articles:
WeChat mini program component form form interpretation and analysis introduction
WeChat mini program Form component sharing
Related video:
WeChat Mini Program Development Document
The above is the detailed content of Form Component_Detailed explanation of mini program form multi-line input box table. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

