小程序表單多行輸入框表格的示例分析

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

成都創(chuàng)新互聯(lián)公司主要從事網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)義縣,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792

多行輸入框。

屬性名類型默認(rèn)值說明
valueString
輸入框的內(nèi)容
placeholderString
輸入框?yàn)榭諘r占位符
placeholder-styleString
指定 placeholder 的樣式
placeholder-classStringtextarea-placeholder指定 placeholder 的樣式類
disabledBooleanfalse是否禁用
maxlengthNumber140最大輸入長度,設(shè)置為 -1 的時候不限制最大長度
auto-focusBooleanfalse自動聚焦,拉起鍵盤。
focusBooleanfalse獲取焦點(diǎn)
auto-heightBooleanfalse是否自動增高,設(shè)置auto-height時,style.height不生效
fixedBooleanfalse如果 textarea 是在一個position:fixed的區(qū)域,需要顯示指定屬性 fixed 為 true
cursor-spacingNumber0指定光標(biāo)與鍵盤的距離,單位 px 。取 textarea 距離底部的距離和 cursor-spacing 指定的距離的最小值作為光標(biāo)與鍵盤的距離
bindfocusEventHandle
輸入框聚焦時觸發(fā),event.detail = {value: value}
bindblurEventHandle
輸入框失去焦點(diǎn)時觸發(fā),event.detail = {value: value}
bindlinechangeEventHandle
輸入框行數(shù)變化時調(diào)用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
bindinputEventHandle
當(dāng)鍵盤輸入時,觸發(fā) input 事件,event.detail = {value: value},bindinput 處理函數(shù)的返回值并不會反映到 textarea 上
bindconfirmEventHandle
點(diǎn)擊完成時, 觸發(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="這個只有在按鈕點(diǎn)擊的時候才聚焦" focus="{{focus}}" />
  <view class="btn-area">
    <button bindtap="bindButtonTap">使得輸入框獲取焦點(diǎn)</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

  1. bug: 微信版本6.3.30,textarea在列表渲染時,新增加的textarea在自動聚焦時的位置計(jì)算錯誤。

  2. tip:textareablur事件會晚于頁面上的tap事件,如果需要在button的點(diǎn)擊事件獲取textarea,可以使用formbindsubmit。

  3. tip: 不建議在多行文本上對用戶的輸入進(jìn)行修改,所以textareabindinput處理函數(shù)并不會將返回值反映到textarea上。

  4. tip:textarea組件是由客戶端創(chuàng)建的原生組件,它的層級是最高的。

  5. tip: 請勿在scroll-view中使用textarea組件。

  6. tip:css動畫對textarea組件無效。

感謝各位的閱讀!關(guān)于“小程序表單多行輸入框表格的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

分享標(biāo)題:小程序表單多行輸入框表格的示例分析
URL標(biāo)題:http://muchs.cn/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)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司