• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Stack
2
3堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。
4
5>  **说明:**
6>
7>  该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
8
9
10## 子组件
11
12可以包含子组件。
13
14
15## 接口
16
17Stack(value?: {alignContent?: Alignment})
18
19**参数:**
20
21| 参数名       | 参数类型                                    | 必填 | 参数描述                                                    |
22| ------------ | ------------------------------------------- | ---- | ----------------------------------------------------------- |
23| alignContent | [Alignment](ts-appendix-enums.md#alignment) | 否   | 设置子组件在容器内的对齐方式。<br/>默认值:Alignment.Center |
24
25## 示例
26
27```ts
28// xxx.ets
29@Entry
30@Component
31struct StackExample {
32  build() {
33    Stack({ alignContent: Alignment.Bottom }) {
34      Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top)
35      Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top)
36    }.width('100%').height(150).margin({ top: 5 })
37  }
38}
39```
40
41![zh-cn_image_0000001219982699](figures/zh-cn_image_0000001219982699.PNG)
42