微信小程序中 input 和 textarea 都有屬性cursor-spacing,可以設置鍵盤與輸入光標的距離,單位px,此外列出input和textarea的特殊屬性
cursor-spacing |
number |
0 |
否 |
指定光標與鍵盤的距離。取 |
input
基礎庫 1.0.0 開始支持,低版本需做兼容處理。
輸入框。該組件是原生組件,使用時請注意相關限制
屬性 | 類型 | 默認值 | 必填 | 說明 | 最低版本 |
---|---|---|---|---|---|
cursor-spacing | number | 0 | 否 | 指定光標與鍵盤的距離,取 input 距離底部的距離和 cursor-spacing 指定的距離的最小值作爲光標與鍵盤的距離 | 1.0.0 |
auto-focus | boolean | false | 否 | (即將廢棄,請直接使用 focus )自動聚焦,拉起鍵盤 | 1.0.0 |
focus | boolean | false | 否 | 獲取焦點 | 1.0.0 |
confirm-type | string | done | 否 | 設置鍵盤右下角按鈕的文字,僅在type='text'時生效 | 1.0.0 |
confirm-hold | boolean | false | 否 | 點擊鍵盤右下角按鈕時是否保持鍵盤不收起 | 1.0.0 |
cursor | number | 是 | 指定focus時的光標位置 | 1.5.0 | |
selection-start | number | -1 | 否 | 光標起始位置,自動聚集時有效,需與selection-end搭配使用 | 1.9.0 |
selection-end | number | -1 | 否 | 光標結束位置,自動聚集時有效,需與selection-start搭配使用 | 1.9.0 |
adjust-position | boolean | true | 否 | 鍵盤彈起時,是否自動上推頁面 | 1.9.90 |
hold-keyboard | boolean | false | 否 | focus時,點擊頁面的時候不收起鍵盤 | 2.8.2 |
textarea
基礎庫 1.0.0 開始支持,低版本需做兼容處理。
多行輸入框。該組件是原生組件,使用時請注意相關限制。
屬性 | 類型 | 默認值 | 必填 | 說明 | 最低版本 |
---|---|---|---|---|---|
auto-focus | boolean | false | 否 | 自動聚焦,拉起鍵盤。 | 1.0.0 |
focus | boolean | false | 否 | 獲取焦點 | 1.0.0 |
auto-height | boolean | false | 否 | 是否自動增高,設置auto-height時,style.height不生效 | 1.0.0 |
fixed | boolean | false | 否 | 如果 textarea 是在一個 position:fixed 的區域,需要顯示指定屬性 fixed 爲 true |
1.0.0 |
cursor-spacing | number | 0 | 否 | 指定光標與鍵盤的距離。取textarea 距離底部的距離和cursor-spacing 指定的距離的最小值作爲光標與鍵盤的距離 |
1.0.0 |
cursor | number | -1 | 否 | 指定focus時的光標位置 | 1.5.0 |
show-confirm-bar | boolean | true | 否 | 是否顯示鍵盤上方帶有”完成“按鈕那一欄 | 1.6.0 |
selection-start | number | -1 | 否 | 光標起始位置,自動聚集時有效,需與selection-end 搭配使用 |
1.9.0 |
selection-end | number | -1 | 否 | 光標結束位置,自動聚集時有效,需與selection-start 搭配使用 |
1.9.0 |
adjust-position | boolean | true | 否 | 鍵盤彈起時,是否自動上推頁面 | 1.9.90 |
hold-keyboard | boolean | false | 否 | focus時,點擊頁面的時候不收起鍵盤 | 2.8.2 |