提交 4de4144b 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

fix: 修改input光标颜色示例

上级 bcbc112d
...@@ -17,12 +17,12 @@ describe('component-native-input', () => { ...@@ -17,12 +17,12 @@ describe('component-native-input', () => {
// 测试焦点及键盘弹起 // 测试焦点及键盘弹起
it('focus', async () => { it('focus', async () => {
const input = await page.$('#uni-input-focus'); 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) // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
await page.setData({ await page.setData({
focus: false, focus: false,
}) })
expect(await input.attribute('focus')).toBe(false) expect(await input.attribute('focus')).toBe("false")
// await page.waitFor(1000) // await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false) // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
// await page.setData({ // await page.setData({
...@@ -141,10 +141,10 @@ describe('component-native-input', () => { ...@@ -141,10 +141,10 @@ describe('component-native-input', () => {
it("cursor-color", async () => { it("cursor-color", async () => {
await page.setData({ await page.setData({
cursor_color: "transparent", cursor_color: "red",
}) })
await page.waitFor(500) 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 () => { it("afterAllTestScreenshot", async () => {
......
...@@ -137,8 +137,9 @@ ...@@ -137,8 +137,9 @@
</view> </view>
<view> <view>
<view class="uni-title" @click="changeCursorColor"> <view class="uni-title" style="flex-direction: row;align-items: center;">
<text class="uni-title-text">设置光标颜色为透明(点击本行文字生效,再点复位)</text> <text class="uni-title-text">设置光标颜色为红色</text>
<switch style="margin-left: 10px;" @change="changeCursorColor" :checked="cursor_color=='red'"></switch>
</view> </view>
<view class="input-wrapper"> <view class="input-wrapper">
<input id="uni-input-cursor-color" class="uni-input" :cursor-color="cursor_color" value="光标颜色" /> <input id="uni-input-cursor-color" class="uni-input" :cursor-color="cursor_color" value="光标颜色" />
...@@ -301,13 +302,16 @@ ...@@ -301,13 +302,16 @@
test_check_input_value():number { test_check_input_value():number {
return this.onMaxLengthInputValue.length return this.onMaxLengthInputValue.length
}, },
changeCursorColor(){ changeCursorColor(event: SwitchChangeEvent){
if(this.cursor_color == "#3393E2"){ const transparent = event.detail.value;
this.cursor_color = "transparent" if(transparent){
}else{ this.cursor_color = "red"
this.cursor_color = "#3393E2" }else{
} this.cursor_color = "#3393E2"
} }
const input = uni.getElementById<UniInputElement>("uni-input-cursor-color")
input?.focus()
},
} }
} }
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册