HarmonyOS 鸿蒙Next 开发者学堂进度条案例代码问题

HarmonyOS 鸿蒙Next 开发者学堂进度条案例代码问题 各位大佬!!!

这个报错怎么解决…

括号嵌套好像没问题,日志报错说无法读取未定义的 abilityInfo 属性,模拟器运行后一片白,有大佬能教下不

图片

图片

图片


更多关于HarmonyOS 鸿蒙Next 开发者学堂进度条案例代码问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

楼主你好,getContext要用真机测试

更多关于HarmonyOS 鸿蒙Next 开发者学堂进度条案例代码问题的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


目前还没真机...
谢谢你的回答。

在HarmonyOS鸿蒙Next开发者学堂中,进度条案例代码通常涉及使用ArkUI框架中的Progress组件。以下是一个简单的进度条实现示例:

import { Progress, Text } from '@ohos.arkui';

@Entry
@Component
struct ProgressExample {
  @State progressValue: number = 0;

  build() {
    Column() {
      Text('当前进度: ' + this.progressValue + '%')
        .fontSize(20)
        .margin({ bottom: 10 });

      Progress({ value: this.progressValue, total: 100 })
        .width('90%')
        .height(20)
        .backgroundColor('#e0e0e0')
        .foregroundColor('#007aff');

      Button('增加进度')
        .onClick(() => {
          if (this.progressValue < 100) {
            this.progressValue += 10;
          }
        })
        .margin({ top: 20 });
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Center)
    .padding(20);
  }
}

该代码创建了一个进度条,点击按钮会增加进度值。Progress组件的value属性表示当前进度,total属性表示最大值。

回到顶部