From 6323dffd7e2839c355454da1115888c1497704cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Tue, 19 Nov 2024 19:51:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20input=E7=BB=84=E4=BB=B6=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E9=A1=B5=E9=9D=A2focus=E9=80=82=E9=85=8D=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/input/input.uvue | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/pages/component/input/input.uvue b/pages/component/input/input.uvue index 261f32d7..097edda4 100644 --- a/pages/component/input/input.uvue +++ b/pages/component/input/input.uvue @@ -140,7 +140,7 @@ 设置输入框聚焦时光标的位置(点这里) - + @@ -150,7 +150,7 @@ + :selection-end="selectionEnd" :focus="selectionInputFocus" @blur="onSelectionBlurChange" /> @@ -160,7 +160,7 @@ - + @@ -297,10 +297,13 @@ showClearIcon: false, inputClearValue: '', showPassword: true, - cursor: -1, + cursor: -1, + cursorInputFocus: false, cursor_color: "#3393E2", + cursorColorInputFocus: false, selectionStart: -1, selectionEnd: -1, + selectionInputFocus: false, inputEventDetail: '', focusAndBlurEventDetail: '', confirmEventDetail: '', @@ -331,19 +334,23 @@ this.onMaxLengthInputValue = event.detail.value }, setCursor: function (cursor : number) { - (this.$refs['input'] as UniInputElement).focus(); + // (this.$refs['input'] as UniInputElement).focus(); + this.cursorInputFocus = true this.cursor = cursor; }, onCursorBlurChange() { - this.cursor = 0 + this.cursor = 0 + this.cursorInputFocus = false }, setSelection: function (selectionStart : number, selectionEnd : number) { - (this.$refs['input2'] as UniInputElement).focus(); + // (this.$refs['input2'] as UniInputElement).focus(); + this.selectionInputFocus = true this.selectionStart = selectionStart; this.selectionEnd = selectionEnd; }, onSelectionBlurChange() { - this.selectionEnd = 0; + this.selectionEnd = 0; + this.selectionInputFocus = false }, clearInput: function (event : UniInputEvent) { this.inputClearValue = event.detail.value @@ -391,8 +398,12 @@ } else { this.cursor_color = "#3393E2" } - const input = uni.getElementById("uni-input-cursor-color") - input?.focus() + // const input = uni.getElementById("uni-input-cursor-color") + // input?.focus() + this.cursorColorInputFocus = true + }, + cursorColorInputBlur(event : UniInputBlurEvent) { + this.cursorColorInputFocus = false }, changeHoldKeyboard(event : UniSwitchChangeEvent) { const checked = event.detail.value; -- GitLab