From 4de4144b151e296176666a9bd5777b3896f66d1e Mon Sep 17 00:00:00 2001 From: taohebin Date: Mon, 15 Jan 2024 11:08:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9input=E5=85=89?= =?UTF-8?q?=E6=A0=87=E9=A2=9C=E8=89=B2=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/input/input.test.js | 8 ++++---- pages/component/input/input.uvue | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js index 0b49607d..a1d7c942 100644 --- a/pages/component/input/input.test.js +++ b/pages/component/input/input.test.js @@ -17,12 +17,12 @@ describe('component-native-input', () => { // 测试焦点及键盘弹起 it('focus', async () => { const input = await page.$('#uni-input-focus'); - expect(await input.attribute('focus')).toBe(true) + expect(await input.attribute('focus')).toBe("true") // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true) await page.setData({ focus: false, }) - expect(await input.attribute('focus')).toBe(false) + expect(await input.attribute('focus')).toBe("false") // await page.waitFor(1000) // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false) // await page.setData({ @@ -141,10 +141,10 @@ describe('component-native-input', () => { it("cursor-color", async () => { await page.setData({ - cursor_color: "transparent", + cursor_color: "red", }) await page.waitFor(500) - expect(await (await page.$('#uni-input-cursor-color')).attribute("cursor-color")).toBe("transparent") + expect(await (await page.$('#uni-input-cursor-color')).attribute("cursor-color")).toBe("red") }) it("afterAllTestScreenshot", async () => { diff --git a/pages/component/input/input.uvue b/pages/component/input/input.uvue index 8fdcb5c0..8f6e2784 100644 --- a/pages/component/input/input.uvue +++ b/pages/component/input/input.uvue @@ -137,8 +137,9 @@ - - 设置光标颜色为透明(点击本行文字生效,再点复位) + + 设置光标颜色为红色 + @@ -301,13 +302,16 @@ test_check_input_value():number { return this.onMaxLengthInputValue.length }, - changeCursorColor(){ - if(this.cursor_color == "#3393E2"){ - this.cursor_color = "transparent" - }else{ - this.cursor_color = "#3393E2" - } - } + changeCursorColor(event: SwitchChangeEvent){ + const transparent = event.detail.value; + if(transparent){ + this.cursor_color = "red" + }else{ + this.cursor_color = "#3393E2" + } + const input = uni.getElementById("uni-input-cursor-color") + input?.focus() + }, } } -- GitLab