赞
踩
- Column() {
- // 容器内元素内容
- }
- .justifyContent('FlexAlign枚举值')
- .alignItems('HorizontalAlign枚举值')
- Row() {
- // 容器内元素内容
- }
- .justifyContent('FlexAlign枚举值')
- .alignItems('VerticalAlign枚举值')
- @Entry
- @Component
- struct Index {
- build() {
- List({space: 30}) {
- ForEach(
- [1,2,3,4,5,6,7,8,9],
- item=>{
- ListItem(){
- Text(`第${item}个元素`)
- .fontWeight(FontWeight.Bold)
- .height(50)
- .lineHeight(50)
- }
- .width('100%')
- .backgroundColor("#FFF")
- .padding(20)
- }
- )
- }
- .width('100%')
- .height('100%')
- .backgroundColor("#999")
- .listDirection('Axis枚举值')
- };
- }
堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。
- @Entry
- @Component
- struct index {
- build() {
- Stack({ alignContent: 'Alignment枚举值' }) {
- Text('First child, show in bottom')
- .width('90%')
- .height('100%')
- .backgroundColor('#999')
- .align(Alignment.Top)
- Text('Second child, show in top')
- .width('70%')
- .height('60%')
- .backgroundColor('#D2CAB3')
- .align(Alignment.Top)
- }
- .width('100%')
- .height(150)
- .margin({ top: 5 })
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。