微信小程序開(kāi)發(fā)文檔
/ 微信小程序表單組件多行輸入框 textarea
微信小程序表單組件多行輸入框 textarea
微信小程序textarea
多行輸入框。
示例代碼:
<!--textarea.wxml--> <view class="section"> <textarea bindblur="bindTextAreaBlur" auto-height placeholder="自動(dòng)變高" /> </view> <view class="section"> <textarea placeholder="placeholder顏色是紅色的" placeholder-style="color:red;" /> </view> <view class="section"> <textarea placeholder="這是一個(gè)可以自動(dòng)聚焦的textarea" auto-focus /> </view> <view class="section"> <textarea placeholder="這個(gè)只有在按鈕點(diǎn)擊的時(shí)候才聚焦" focus="{{focus}}" /> <view class="btn-area"> <button bindtap="bindButtonTap">使得輸入框獲取焦點(diǎn)</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
: 微信版本6.3.30
,textarea
在列表渲染時(shí),新增加的textarea
在自動(dòng)聚焦時(shí)的位置計(jì)算錯(cuò)誤tip
: 請(qǐng)勿在scroll-view
中使用textarea
組件