@Entry
@Component
struct Index {
@State value: string = '';
build() {
Column() {
Swiper() {
Image($r('app.media.layered_image'))
Image($r('app.media.haha'))
Image($r('app.media.background'))
Image($r('app.media.foreground'))
}
.width('100%')
.aspectRatio(2.4) // 设置和图片一致的宽高比, 保证图片正常适配
.autoPlay(true)
.interval(1000)
.indicator(
Indicator.dot() // 小圆点
.itemWidth(30) // 默认的宽
.itemHeight(20) // 默认的高
.color(Color.Pink) // 默认的颜色
.selectedItemWidth(60) // 选中的宽
.selectedItemHeight(40) // 选中的高
.selectedColor(Color.Red) // 选中的颜色
)
}
}
}
Swiper轮播组件使用
最新推荐文章于 2024-09-05 18:38:45 发布