HarmonyOS【ArkUI组件--TextInput】

1.文本输入框基本用法

2. 使用文本输入框组件(如何实现输入数字改变图片大小)

在此博客的基础上继续编写:HarmonyOS【ArkUI组件--Text】-CSDN博客

①代码如下:

javascript 复制代码
import font from '@ohos.font'
@Entry
@Component
struct Index {
  @State imageWidth:number= 30

  build() {
    Row() {
      Column() {

        Image($r('app.media.app_icon'))
          .width(this.imageWidth)
          .interpolation(ImageInterpolation.High)
        Text($r('app.string.width_label'))
          .fontSize(20)
          .fontWeight(FontWeight.Bold)
        TextInput({text:this.imageWidth.toFixed(0)})
          .width(150)
          .backgroundColor('#36D')
          .type(InputType.Number)
          .onChange(value => {
            this.imageWidth=parseInt(value)
          })
      }

      .width('100%')
    }
    .height('100%')
  }
}

②效果如下


关于博客有任何问题欢迎咨询 ,看见就回😊

相关推荐
bst@微胖子10 小时前
鸿蒙实现滴滴出行项目之线路规划图
华为·harmonyos
路很长OoO12 小时前
Flutter 插件开发实战:桥接原生 SDK
前端·flutter·harmonyos
2501_9197490314 小时前
鸿蒙:使用Rating组件实现五角星打分评价
华为·harmonyos
2501_9197490319 小时前
鸿蒙:实现滑动选择日期操作
华为·harmonyos
程序员潘Sir21 小时前
鸿蒙应用开发从入门到实战(十九):样式复用案例
harmonyos·鸿蒙
2501_919749031 天前
鸿蒙:使用@Reusable实现组件的复用,提升性能
华为·harmonyos
爱笑的眼睛112 天前
HarmonyOS SaveButton深度解析:安全便捷的媒体资源保存方案
安全·华为·harmonyos·媒体
无风听海2 天前
HarmonyOS之Emitter
harmonyos
光芒Shine2 天前
【ArkTS-通用事件】
harmonyos