HarmonyOS textinput还未输入完成会自动跳转到下1个输入框

textinput还未输入完成,会自动跳转到下1个输入框。Swiper中新增1个SwiperItem后textinput输入就会自动跳转到下1个 (SwiperItem中的输入框是循环生成的)。

HarmonyOS
2025-01-09 16:22:24
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

可以为forEach循环的时候添加键值,有关forEach的使用可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-rendering-control-foreach-V5#非首次渲染

修改部分代码如下:

ForEach(this.areasList.sort((a, b) => Number(b.isrequired) - Number(a.isrequired)),
  (item: InfoModel, index: number) => {
    ListItem() {
      Column() {
        Row() {
          Row() {
            Text(item.name).fontSize(16)
              .fontColor('#000').height(60).margin({ left: 5 })
          }

          TextInput({
            text: item.result,
          })
            .type(this.inputType(item))
            .enterKeyType(EnterKeyType.Next)
            .onChange((value) => {
              item.result = value
            })
            .textAlign(TextAlign.End)
            .width('60%')
            .height(40)
            .fontSize(14)
            .backgroundColor('#fff')
            .borderRadius(0)
            .focusable(item.datatype == 'date' ? false : true)
            .onClick(() => {
              if (item.datatype == 'date') {
                CalendarPickerDialog.show({
                  selected: this.selectedDate,
                  onAccept: (value) => {
                    item.result = value.toString() // DateUtil.getFormatDateStr(value, 'yyyy年MM月dd日')
                    this.areasList.splice(index, 1, item)
                  },
                  onCancel: () => {
                    console.info("calendar onCancel")
                  },
                  onChange: (value) => {
                    console.info("calendar onChange:" + JSON.stringify(value))
                  }
                })
              }
            })
        }
        .width('100%')
        .height(40)
        .backgroundColor('#fff')
        .justifyContent(FlexAlign.SpaceBetween)
        .padding({ left: 5, right: 5 })

        Divider().color('#ccc')
      }.margin({ top: 10 })
    }
  }, (item: InfoModel) => item.name)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
分享
微博
QQ
微信
回复
2025-01-09 18:24:23
相关问题
HarmonyOS textInput 如何清空输入框
910浏览 • 2回复 待解决
HarmonyOS 输入框自动避让偏移值
552浏览 • 1回复 待解决
获取输入框输入的内容
449浏览 • 2回复 待解决
HarmonyOS 密码输入框
781浏览 • 1回复 待解决
HarmonyOS 输入框只能输入字母和数字
1073浏览 • 1回复 待解决
HarmonyOS 适配-输入框问题
805浏览 • 1回复 待解决
HarmonyOS 输入框无法对齐
1123浏览 • 1回复 待解决
HarmonyOS 键盘遮挡输入框
706浏览 • 1回复 待解决
HarmonyOS 修改输入框焦点
735浏览 • 1回复 待解决