space属性只有API12才支持,请参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-flex-V5\#flexoptions%E5%AF%B9%E8%B1%A1%E8%AF%B4%E6%98%8Eimport { LengthMetrics } from '@kit.ArkUI'; @Entry @Component struct Page1 { @State message: string = 'Hello World'; build() { Flex({ wrap: FlexWrap.Wrap, space: { main: LengthMetrics.px(50), cross: LengthMetrics.px(50) } }) { // 子组件多行布局 Text('1').width('40%').height(50).backgroundColor(0xF5DEB3) Text('2').width('40%').height(50).backgroundColor(0xD2B48C) Text('3').width('40%').height(50).backgroundColor(0xD2B48C) } .width('90%') .padding(10) .backgroundColor(0xAFEEEE) } }
space属性只有API12才支持,请参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-flex-V5\#flexoptions%E5%AF%B9%E8%B1%A1%E8%AF%B4%E6%98%8E