harmony 鸿蒙arkui子系统ChangeLog

  • 2023-10-30
  • 浏览 (419)

arkui子系统ChangeLog

cl.arkui.1 系统组件父子校验

从API version11开始,当BlankFlowItemGridItemGridColListItemListItemGroupOptionSpanStepperItemTabContent组件的父组件不是限定组件时,编译报错。

示例:

@Entry
@Component
struct Index {
  build() {
    Button(){
      Blank()
    }
  }
}

变更影响

如果BlankFlowItemGridItemGridColListItemListItemGroupSpanStepperItemTabContent组件的父组件没有写在限定的组件中,编译报错 。父组件为if组件,ForEach组件,LazyForEach组件, @Builder修饰的方法中,编译不会报错。

// ArkTS:ERROR The 'Blank' component can only be nested in the 'Row,Column,Flex' parent component.
Button(){
      Blank()
    }

关键的接口/组件变更

不涉及。

适配指导

请查阅Blank组件FlowItem组件GridItem组件GridCol组件ListItem组件ListItemGroup组件Span组件StepperItem组件TabContent组件文档进行适配。

cl.arkui.2 Flex组件wrap模式尺寸约束属性constraintSize生效变更

从API version 11开始,当Flex组件wrap模式下使用属性constraintSize可以正常对交叉轴约束生效。

示例:

@Entry
@Component
struct ClipExample1 {
  @State message: string = 'Hello World'
  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Flex({wrap:FlexWrap.Wrap}) {
          Text('1').height(50).backgroundColor(Color.Gray)
          Text('天天向上').height(50).backgroundColor(Color.Gray)
          Text('天天向上向上').height(50).backgroundColor(Color.Gray)
          Text('天天向上向上天天向上向上').height(50).backgroundColor(Color.Gray)
          Text('1天天向上向上').height(50).backgroundColor(Color.Gray)
          Text('1天天向上向上').height(50).backgroundColor(Color.Gray)
          Text('天天向上向上天天向上向上').height(50).backgroundColor(Color.Gray)
          Text('天天向上向上天天向上向上').height(50).backgroundColor(Color.Gray)
          Text('1').height(50).backgroundColor(Color.Gray)
          Text('1').height(50).backgroundColor(Color.Gray)
          Text('1').height(50).backgroundColor(Color.Gray)
        }
        .clip(true)
        .backgroundColor(Color.Orange)
        .constraintSize({
          minHeight: 50,
          maxHeight: 150
        })
      }
      .width('100%')
    }.height('100%').width(300)
  }
}

变更影响

变更前示例中Flex组件实际高度为200,没有受constraintSize中maxHeight约束,变更后constraintSize约束能正常生效,最小高度为50,最大高度为150,最大最小宽度约束同理可正常生效。

适配指导

若之前使用了wrap并且设置了constraintSize并未对Flex容器大小约束成功,API version 11及以上版本会正常生效,应用若不想要该约束则将constraintSize移除或调整约束数值。

cl.arkui.3 Scroll组件currentOffset接口变更

访问级别

公开接口。

变更原因

currentOffset接口的返回值为any,不利于代码开发时的自动提示。

变更影响

该变更为非兼容性变更,Scroll组件中currentOffset接口的返回值由any变更为OffsetResult。

API Level

11

变更发生版本

从OpenHarmony SDK 4.1.2.3开始。

变更的接口/组件

API version 10前 ,currentOffset接口的返回值为any:

currentOffset();

API version 11及以后,currentOffset接口的返回值为OffsetResult:

currentOffset() : OffsetResult;

适配指导

不涉及

你可能感兴趣的鸿蒙文章

harmony 鸿蒙分布式设备管理子系统变更说明

harmony 鸿蒙multimedia子系统ChangeLog

harmony 鸿蒙上传下载子系统ChangeLog

0  赞