哪个网站做职客比较好 比较正规,平台如何制作网站,海南网站建设fwlit,怎么申请网址怎么用一、背景
项目中通常会遇到图片轮播#xff0c;内容轮播的场景#xff1b;如#xff1a;在一些应用首页显示推荐的内容时#xff0c;需要用到轮播显示的能力。
二、源码地址 ✍Gitee开源项目地址#x1f449;#xff1a;https://gitee.com/cheinlu/harmony-os-next-swi…一、背景
项目中通常会遇到图片轮播内容轮播的场景如在一些应用首页显示推荐的内容时需要用到轮播显示的能力。
二、源码地址 ✍Gitee开源项目地址https://gitee.com/cheinlu/harmony-os-next-swiper 文档地址文档中心
三、实现效果 四、代码示例
Entry
Component
struct Index {//轮播图数据源State swiperList: ResourceStr[] [$r(app.media.swiper_one), $r(app.media.swiper_two), $r(app.media.swiper_three), $r(app.media.swiper_four),$r(app.media.swiper_five)]State selectedIndex: number 0 //默认选中索引为0build() {Stack({ alignContent: Alignment.Bottom }) {Swiper() {ForEach(this.swiperList, (item: ResourceStr, index: number) {Image(item).width(100%).height(100%)})}.onChange((index: number) {this.selectedIndex index}).autoPlay(true).indicator(false).itemSpace(0).width(100%).height(100%)//此处为自定义角标if (this.swiperList.length 1) {List({ space: 5 }) {ForEach(this.swiperList, (item: ResourceStr, index: number) {ListItem() {Image(this.selectedIndex index ? $r(app.media.carousel_blue) : $r(app.media.carousel_gary)).width(20).aspectRatio(1)}})}.listDirection(Axis.Horizontal).align(Alignment.Center).enableScrollInteraction(false).hitTestBehavior(HitTestMode.Transparent).constraintSize({ maxWidth: 90% }).height(20).margin({ left: 20, bottom: 20, right: 20 })}}}
}
4.1、属性说明 autoPlay子组件是否自动播放。默认值false indicator是否启用导航点指示器。默认值true itemSpace设置子组件与子组件之间间隙。默认值0。说明不支持设置百分比。 4.2、自定义角标
官方文档默认角标效果 通过如下代码更改角标样式更换成菱形图片选中与未选中替换样式 踩坑不易还希望各位大佬支持一下 我的土拨鼠开源项目 ✍Gitee开源项目地址https://gitee.com/cheinlu/groundhog-charging-system ✍GitHub开源项目地址https://github.com/cheinlu/groundhog-charging-system 我的鸿蒙NEXT轮播图开源组件https://gitee.com/cheinlu/harmony-os-next-swiper 最后