字節(jié)跳動(dòng)小程序開發(fā)組件文檔 textarea

2019-08-09 14:28 更新

多行輸入框。

屬性名 類型 默認(rèn)值 說(shuō)明 最低版本
value String 輸入框的內(nèi)容 1.0.0
placeholder String 輸入框?yàn)榭諘r(shí)占位符 1.0.0
placeholder-style String 指定 placeholder 的樣式 1.0.0
disabled Boolean false 是否禁用 1.0.0
maxlength Number 140 最大輸入長(zhǎng)度,設(shè)置為 -1 的時(shí)候不限制最大長(zhǎng)度 1.0.0
focus Boolean false 是否獲得焦點(diǎn) 1.0.0
auto-height Boolean false 是否自動(dòng)增高,設(shè)置auto-height時(shí),設(shè)置height樣式不生效 1.0.0
fixed Boolean false 是否固定位置,如果設(shè)置了css樣式position:fixed,需要將改屬性設(shè)置為true 1.0.0
cursor-spacing Number 0 指定軟鍵盤彈出時(shí),與光標(biāo)的距離是多少,單位是px 1.0.0
cursor Number -1 指定focus時(shí)的光標(biāo)位置 1.0.0
selection-start Number -1 指定focus時(shí)選中片段的起始位置 1.0.0
selection-end Number -1 指定focus時(shí)選中片段的結(jié)束位置 1.0.0
bindinput EventHandler 鍵盤輸入時(shí)觸發(fā),e.detail={value, cursor} 1.0.0
bindfocus EventHandler 輸入框聚焦時(shí)觸發(fā),event.detail={value,height},height是軟鍵盤的高度 1.0.0
bindblur EventHandler 輸入框失去焦點(diǎn)時(shí)觸發(fā),event.detail={value} 1.0.0
bindconfirm EventHandler 用戶點(diǎn)擊鍵盤的完成按鈕時(shí)觸發(fā),event.detail={value} 1.0.0

WARNING

  1. 請(qǐng)勿在 scroll-view、swiper、picker-view 中使用 textarea 組件
  2. css 動(dòng)畫對(duì) textarea 組件無(wú)效
  3. 如果樣式上設(shè)置為fixed元素,請(qǐng)?jiān)诮M件上添加fixed屬性

示例


開發(fā)者工具中預(yù)覽

<textarea
    bindfocus="onTextFocus"
    bindblur="onTextBlur"
    bindinput="onTextInput"
    bindconfirm="onTextConfirm"
    placeholder="請(qǐng)輸入"
/>

<text>用戶輸入:{{value}}</text>
Page({
  data: {
    value: ''
  },
  onTextFocus: function (e) {
    console.log(e)
  },
  onTextBlur: function (e) {
    console.log(e)
  },
  onTextInput: function (e) {
    this.setData({
      value: e.detail.value
    })
  },
  onTextConfirm: function (e) {
    tt.showToast({title: 'confirm'})
  }
})


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)