Documentation de développement de l'applet WeChat
/ 微信小程序表單組件多行輸入框 textarea
微信小程序表單組件多行輸入框 textarea
微信小程序textarea
多行輸入框。
示例代碼:
<!--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
: 微信版本6.3.30
,textarea
在列表渲染時,新增加的textarea
在自動聚焦時的位置計算錯誤tip
: 請勿在scroll-view
中使用textarea
組件