WeChat applet form component multi-line input box textarea
WeChat applet textarea
Multi-line input box.
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>
//textarea.js Page({ data: { height: 20, focus: false }, bindButtonTap: function() { this.setData({ focus: true }) }, bindTextAreaBlur: function(e) { console.log(e.detail.value) } })
Bug & Tip
- ##bug
: WeChat version
6.3.30,
textareaWhen rendering the list, the position calculation error of the newly added
textareaduring auto focus
- tip
: Do not use
textareacomponent
in
scroll-view