diff --git a/packages/field/README.md b/packages/field/README.md index a301423b..77b2e073 100644 --- a/packages/field/README.md +++ b/packages/field/README.md @@ -169,6 +169,8 @@ Page({ | cursor-spacing | 输入框聚焦时底部与键盘的距离 | `Number` | `50` | | adjust-position | 键盘弹起时,是否自动上推页面 | `Boolean` | `true` | | show-confirm-bar | 是否显示键盘上方带有”完成“按钮那一栏,只对 textarea 有效 | `Boolean` | `true` | +| selection-start | 光标起始位置,自动聚集时有效,需与 selection-end 搭配使用 | `Number` | `-1` | +| selection-end | 光标结束位置,自动聚集时有效,需与 selection-start 搭配使用 | `Number` | `-1` | ### Events diff --git a/packages/field/index.ts b/packages/field/index.ts index 73b20e82..16faad8e 100644 --- a/packages/field/index.ts +++ b/packages/field/index.ts @@ -32,6 +32,14 @@ VantComponent({ placeholder: String, placeholderStyle: String, errorMessageAlign: String, + selectionEnd: { + type: Number, + value: -1 + }, + selectionStart: { + type: Number, + value: -1 + }, showConfirmBar: { type: Boolean, value: true diff --git a/packages/field/index.wxml b/packages/field/index.wxml index ab3ad5dc..1a3e9afd 100644 --- a/packages/field/index.wxml +++ b/packages/field/index.wxml @@ -27,6 +27,8 @@ cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" show-confirm-bar="{{ showConfirmBar }}" + selection-end="{{ selectionEnd }}" + selection-start="{{ selectionStart }}" bindinput="onInput" bind:blur="onBlur" bind:focus="onFocus" @@ -51,6 +53,8 @@ confirm-hold="{{ confirmHold }}" cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" + selection-end="{{ selectionEnd }}" + selection-start="{{ selectionStart }}" password="{{ password || type === 'password' }}" bindinput="onInput" bind:blur="onBlur"