這篇文章給大家分享的是有關(guān)小程序表單多行輸入框表格的示例分析的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

成都創(chuàng)新互聯(lián)公司主要從事網(wǎng)站設(shè)計制作、網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)義縣,十多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
多行輸入框。
| 屬性名 | 類型 | 默認值 | 說明 |
|---|---|---|---|
| value | String | 輸入框的內(nèi)容 | |
| placeholder | String | 輸入框為空時占位符 | |
| placeholder-style | String | 指定 placeholder 的樣式 | |
| placeholder-class | String | textarea-placeholder | 指定 placeholder 的樣式類 |
| disabled | Boolean | false | 是否禁用 |
| maxlength | Number | 140 | 最大輸入長度,設(shè)置為 -1 的時候不限制最大長度 |
| auto-focus | Boolean | false | 自動聚焦,拉起鍵盤。 |
| focus | Boolean | false | 獲取焦點 |
| auto-height | Boolean | false | 是否自動增高,設(shè)置auto-height時,style.height不生效 |
| fixed | Boolean | false | 如果 textarea 是在一個position:fixed的區(qū)域,需要顯示指定屬性 fixed 為 true |
| cursor-spacing | Number | 0 | 指定光標與鍵盤的距離,單位 px 。取 textarea 距離底部的距離和 cursor-spacing 指定的距離的最小值作為光標與鍵盤的距離 |
| bindfocus | EventHandle | 輸入框聚焦時觸發(fā),event.detail = {value: value} | |
| bindblur | EventHandle | 輸入框失去焦點時觸發(fā),event.detail = {value: value} | |
| bindlinechange | EventHandle | 輸入框行數(shù)變化時調(diào)用,event.detail = {height: 0, heightRpx: 0, lineCount: 0} | |
| bindinput | EventHandle | 當(dāng)鍵盤輸入時,觸發(fā) input 事件,event.detail = {value: value},bindinput 處理函數(shù)的返回值并不會反映到 textarea 上 | |
| bindconfirm | EventHandle | 點擊完成時, 觸發(fā) 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
bug: 微信版本6.3.30,textarea在列表渲染時,新增加的textarea在自動聚焦時的位置計算錯誤。
tip:textarea 的blur事件會晚于頁面上的tap事件,如果需要在button的點擊事件獲取textarea,可以使用form的bindsubmit。
tip: 不建議在多行文本上對用戶的輸入進行修改,所以textarea的bindinput處理函數(shù)并不會將返回值反映到textarea上。
tip:textarea組件是由客戶端創(chuàng)建的原生組件,它的層級是最高的。
tip: 請勿在scroll-view中使用textarea組件。
tip:css動畫對textarea組件無效。
感謝各位的閱讀!關(guān)于“小程序表單多行輸入框表格的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
分享標題:小程序表單多行輸入框表格的示例分析
URL標題:http://chinadenli.net/article14/ipgpde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、品牌網(wǎng)站制作、全網(wǎng)營銷推廣、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)