diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js index 0b49607d5aa70d67da1aaa4ed13ff203c6b520fa..a1d7c942125cbda9b933047b02dea9826c589c8a 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 8fdcb5c0b072b1dd86dea7c642cae6676720feb1..8f6e2784b865e6142edb7ff611320b520c02a8e2 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() + }, } }