多行輸入框。
屬性名稱 | 類型 | 預設值 | 說明 |
---|---|---|---|
value | String | 輸入框的內容 | |
placeholder | #String | 輸入框為空時佔位符 | |
placeholder-style | #String | 指定 placeholder 的樣式 | |
placeholder-class | ##String | textarea-placeholder | 指定 placeholder 的樣式類別 |
disabled | #Boolean | #false | 是否禁用 |
maxlength | Number | 140 | 最大輸入長度,設定為 -1 的時候不限制最大長度 |
auto-focus | Boolean | #false | 自動對焦,拉起鍵盤。 |
focus | Boolean | #false | 取得焦點 |
auto-height | #Boolean | #false | 是否自動增高,設定auto-height時,style.height不生效 |
fixed | #Boolean | #false | 如果 textarea 是在一個position:fixed 的區域,則需要顯示指定屬性 fixed 為 true |
cursor-spacing | Number | 0 | 指定遊標與鍵盤的距離,單位 px 。取 textarea 距離底部的距離和 cursor-spacing 指定的距離的最小值作為遊標與鍵盤的距離 |
bindfocus | EventHandle | # | 輸入框聚焦時觸發,event.detail = {value: value} |
bindblur | ##EventHandle | # | 輸入框失去焦點時觸發,event.detail = {value: value} |
bindlinechange | ##EventHandle | # | 輸入框行數變化時調用,event.detail = {height: 0, heightRpx: 0, lineCount: 0} |
bindinput | ##EventHandle | # | 當鍵盤輸入時,觸發 input 事件,event.detail = {value: value},bindinput 處理函數的回傳值不會反映在 textarea 上 |
bindconfirm | EventHandle | # | 點擊完成時, 觸發 confirm 事件,event.detail = {value: value} |
# 範例程式碼:
<!--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
##錯誤
# : 微信版本
6.3.30,
textarea在清單渲染時,新增加的
textarea在自動聚焦時的位置計算錯誤。
tip
:
textarea的
blur事件會晚於頁面上的
tap1 ,如果需要在
button的點擊事件取得
textarea,可以使用
form的
bindsubmit。
tip
: 不建議在多行文字上對使用者的輸入進行修改,所以
textarea的
bindinput處理函數並不會將回傳值反映在
textarea上。
tip
:
textarea元件是由客戶端建立的原生元件,它的層級是最高的。
tip
: 請勿在
scroll-view中使用
textarea元件。
tip
:
css動畫對
textarea元件無效。
以上是表單組件_小程式表單多行輸入框表格詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

Atom編輯器mac版下載
最受歡迎的的開源編輯器