提交 5aba11d1 编写于 作者: S swx1239486

修改侧边栏demo,使之正常运行

Signed-off-by: Nswx1239486 <songqinqin4@huawei.com>
上级 dc802299
...@@ -352,8 +352,9 @@ struct MultiLaneList { ...@@ -352,8 +352,9 @@ struct MultiLaneList {
@Component @Component
struct SideBarSample { struct SideBarSample {
@StorageLink('currentBreakpoint') private currentBreakpoint: string = "md"; @StorageLink('currentBreakpoint') private currentBreakpoint: string = "md";
private breakpointSystem: BreakpointSystem = new BreakpointSystem() private breakpointSystem: BreakpointSystem = new BreakpointSystem();
@State selectIndex: number = 0; @State selectIndex: number = 0;
@State showSideBar:boolean=false;
aboutToAppear() { aboutToAppear() {
this.breakpointSystem.register() this.breakpointSystem.register()
...@@ -374,7 +375,10 @@ struct SideBarSample { ...@@ -374,7 +375,10 @@ struct SideBarSample {
.width(180) .width(180)
.height(36) .height(36)
.onClick(() => { .onClick(() => {
this.selectIndex = index this.selectIndex = index;
if(this.currentBreakpoint === 'sm'){
this.showSideBar=false
}
}) })
} }
...@@ -402,8 +406,11 @@ struct SideBarSample { ...@@ -402,8 +406,11 @@ struct SideBarSample {
.maxSideBarWidth(this.currentBreakpoint === 'sm' ? '100%' : '33.33%') .maxSideBarWidth(this.currentBreakpoint === 'sm' ? '100%' : '33.33%')
.showControlButton(this.currentBreakpoint === 'sm') .showControlButton(this.currentBreakpoint === 'sm')
.autoHide(false) .autoHide(false)
.showSideBar(this.currentBreakpoint !== 'sm'||this.showSideBar)
.onChange((isBarShow: boolean) => { .onChange((isBarShow: boolean) => {
if(this.currentBreakpoint === 'sm'){
this.showSideBar=isBarShow
}
}) })
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册