可以使用indicator设置颜色透明,让它不显示。详细内容请参见:https://developer.huawei.com/consumer/cn/doc/harmonyos-refere....indicator(Indicator.dot() .itemWidth(15) .itemHeight(15) .selectedItemWidth(15) .selectedItemHeight(15) .color('#00000000') .selectedColor('#00000000'))设置透明是替换方案,单独设置indicator也是可以生效的,参考demo: // xxx.ets class MyDataSource implements IDataSource { private list: number[] = [] constructor(list: number[]) { this.list = list } totalCount(): number { return this.list.length } getData(index: number): number { return this.list[index] } registerDataChangeListener(listener: DataChangeListener): void { } unregisterDataChangeListener() { } } @Entry @Component struct SwiperExample { private swiperController: SwiperController = new SwiperController() private data: MyDataSource = new MyDataSource([]) aboutToAppear(): void { let list: number[] = [] for (let i = 1; i <= 10; i++) { list.push(i); } this.data = new MyDataSource(list) } build() { Column({ space: 5 }) { Swiper(this.swiperController) { LazyForEach(this.data, (item: string) => { Text(item.toString()) .width('90%') .height(160) .backgroundColor(0xAFEEEE) .textAlign(TextAlign.Center) .fontSize(30) }, (item: string) => item) } .cachedCount(2) .index(1) .autoPlay(true) .interval(4000) .loop(true) .duration(1000) .itemSpace(0) // .indicator( // 设置圆点导航点样式 // new DotIndicator() // .itemWidth(15) // .itemHeight(15) // .selectedItemWidth(15) // .selectedItemHeight(15) // .color(Color.Gray) // .selectedColor(Color.Blue)) .indicator(false) // .loop(false) // .indicator(Indicator.dot() // .itemWidth(15) // .itemHeight(15) // .selectedItemWidth(15) // .selectedItemHeight(15) // .color('#00000000') // .selectedColor('#00000000')) .displayArrow({ // 设置导航点箭头样式 showBackground: true, isSidebarMiddle: true, backgroundSize: 24, backgroundColor: Color.White, arrowSize: 18, arrowColor: Color.Blue }, false) .curve(Curve.Linear) .onChange((index: number) => { console.info(index.toString()) }) .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { console.info("index: " + index) console.info("current offset: " + extraInfo.currentOffset) }) .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { console.info("index: " + index) console.info("targetIndex: " + targetIndex) console.info("current offset: " + extraInfo.currentOffset) console.info("target offset: " + extraInfo.targetOffset) console.info("velocity: " + extraInfo.velocity) }) .onAnimationEnd((index: number, extraInfo: SwiperAnimationEvent) => { console.info("index: " + index) console.info("current offset: " + extraInfo.currentOffset) }) Row({ space: 12 }) { Button('showNext') .onClick(() => { this.swiperController.showNext() }) Button('showPrevious') .onClick(() => { this.swiperController.showPrevious() }) }.margin(5) }.width('100%') .margin({ top: 5 }) } } 本文参与了 【 HarmonyOS NEXT 技术问答冲榜,等你来战!】欢迎正在阅读的你也加入。
可以使用indicator设置颜色透明,让它不显示。详细内容请参见:
https://developer.huawei.com/consumer/cn/doc/harmonyos-refere...
设置透明是替换方案,单独设置indicator也是可以生效的,参考demo:
本文参与了 【 HarmonyOS NEXT 技术问答冲榜,等你来战!】欢迎正在阅读的你也加入。