本示例通过定义层级实现多层折叠面板,并在首页性能文章tab实际使用跳转到对应文章的web页面。
使用说明
定义好菜单各层级的数据源,可以由父级传入也可以固定,本案例为固定数据源。
根据当前层级节点是否存在children判断是否可展开,以此实现折叠效果,本案例使用三级四级效果。
折叠面板的列表项传入固定数据源。
if (this.thirdLevelCategory.childNodes?.length > 0) {
Image(this.isUnfold ? $r('app.media.ic_down_arrow') : $r('app.media.ic_right_arrow'))
.width(this.isUnfold ? 24 : 12)
.height(this.isUnfold ? 12 : 24)
.margin({ right: this.isUnfold ? 0 : 6 })
}
欢迎大家关注公众号<程序猿百晓生>,可以了解到一下知识点。
1.OpenHarmony开发基础
2.OpenHarmony北向开发环境搭建
3.鸿蒙南向开发环境的搭建
4.鸿蒙生态应用开发白皮书V2.0 & V3.0
5.鸿蒙开发面试真题(含参考答案)
6.TypeScript入门学习手册
7.OpenHarmony 经典面试题(含参考答案)
8.OpenHarmony设备开发入门【最新版】
9.沉浸式剖析OpenHarmony源代码
10.系统定制指南
11.【OpenHarmony】Uboot 驱动加载流程
12.OpenHarmony构建系统--GN与子系统、部件、模块详解
13.ohos开机init启动流程
14.鸿蒙版性能优化指南
.......
Row() {
Text(this.thirdLevelCategory.title)
.fontSize(16)
.margin({ left: 16 })
.fontFamily('HarmonyHeiTi-Medium')
.fontColor($r('app.color.font_color_dark'))
Blank()
if (this.thirdLevelCategory.childNodes?.length > 0) {
Image(this.isUnfold ? $r('app.media.ic_down_arrow') : $r('app.media.ic_right_arrow'))
.width(this.isUnfold ? 24 : 12)
.height(this.isUnfold ? 12 : 24)
.margin({ right: this.isUnfold ? 0 : 6 })
}
}
.height(56)
.width('100%')
.onClick(() => {
if (this.thirdLevelCategory.childNodes?.length === 0) {
DynamicsRouter.pushUri('collapsemenu/ArticleWebComponent', this.thirdLevelCategory);
AppStorage.setOrCreate('articleWebUrl', this.thirdLevelCategory.url)
} else {
this.isUnfold = !this.isUnfold;
}
})
collapsemenu // har类型
|---src/main/ets/component
| |---collapseMenu.ets // 视图层-主页
|---src/main/ets/model
| |---articleList.ets // 模型层-性能文章列表
| |---articleWebComponent.ets // 视图层-web页面
| |---categoricalDataType.ets // 模型层-类型定义
如果你觉得这篇内容对你还蛮有帮助,我想邀请你帮我三个小忙:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。