SideBarContainer 表示侧边栏容器,它可以添加两个子组件,第一个子组件表示侧边栏,第二个子组件表示内容区,本节笔者简单介绍一下 SideBarContainer 的简单使用。
SideBarContainer定义介绍
interface SideBarContainerInterface {
(type?: SideBarContainerType): SideBarContainerAttribute;
}
- type:
设置侧边栏的显示类型, SideBarContainerType 定义了一下 2 中类型:
-
- Embed:侧边栏嵌入到组件内,侧边栏和内容区并列显示。
- Overlay:侧边栏浮在内容区上面。
简单实例如下所示:
@Entry
@Component
struct SideBarContainerTest {
build() {
SideBarContainer(SideBarContainerType.Overlay) {
Column() {
Text("侧边栏区域")
.width("100%")
.height("100%")
.fontSize(30)
.textAlign(TextAlign.Center)
}
.width(10)
.height("100%")
.backgroundColor("#aabbcc")
Column() {
Text("侧边栏区域")
.width("100%")
.height("100%")
.fontSize(30)
.textAlign(Te