HarmonyOS textarea展示最新数据问题

HarmonyOS textarea展示最新数据问题 -鸿蒙开发者社区

如图所示用textarea存放展示操作日志,如何展示最新的日志。现在需要手动拖动侧边滚动条拉倒最下。

HarmonyOS
2024-12-25 12:45:42
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

示例参考如下:

// xxx.ets
@Entry
@Component
struct TextAreaExample {
  @State text: string = ''
  @State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 }
  controller: TextAreaController = new TextAreaController()
  @State maxLength: number= 0

  build() {
    Column() {
      TextArea({
        text: this.text,
        placeholder: 'The text area can hold an unlimited amount of text. input your word...',
        controller: this.controller
      })
        .placeholderFont({ size: 16, weight: 400 })
        .width(336)
        .height(56)
        .margin(20)
        .fontSize(16)
        .fontColor('#182431')
        .backgroundColor('#FFFFFF')
        .onChange((value: string) => {
          let Length: number= value.length;
          if(this.maxLength< Length){
            this.maxLength = Length
            console.log('length='+this.maxLength)
          }
          this.text = value
        })
      Text(this.text)

      Button('跳转到最后一行').onClick((event: ClickEvent) => {
        this.controller.caretPosition(this.maxLength)
      })
    }.width('100%').height('100%').backgroundColor('#F1F3F5')
  }
}

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textarea-V5

分享
微博
QQ
微信
回复
2024-12-25 16:26:43
相关问题
HarmonyOS RichText 展示问题
263浏览 • 1回复 待解决
HarmonyOS TextArea获取焦点
47浏览 • 1回复 待解决
HarmonyOS Slider UI展示问题
739浏览 • 1回复 待解决
HarmonyOS DatePicker组件年份展示问题
632浏览 • 1回复 待解决
HarmonyOS List展示不全的问题
480浏览 • 1回复 待解决
HarmonyOS 实况窗无法展示问题
275浏览 • 1回复 待解决
HarmonyOS 列表展示list懒加载问题
803浏览 • 1回复 待解决
HarmonyOS TextPicker多级联动的展示问题
193浏览 • 1回复 待解决
HarmonyOS 组件的合理展示等相关问题
248浏览 • 1回复 待解决
HarmonyOS 自定义相机拍照后数据展示
1047浏览 • 1回复 待解决
HarmonyOS TextArea与系统键盘的使用方式
184浏览 • 1回复 待解决
HarmonyOS TextArea如何设置单行的行高?
388浏览 • 1回复 待解决