微信小程序中 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 |