HomeLease/components/banner-swiper/banner-swiper.vue

92 lines
1.6 KiB
Vue
Raw Normal View History

2025-08-13 11:10:19 +08:00
<template>
<view class="banner-section">
<swiper
:autoplay="autoplay"
:duration="duration"
:indicator-dots="indicatorDots"
:interval="interval"
circular
class="swiper"
2025-08-13 11:43:35 +08:00
indicator-active-color="#F15A04"
indicator-color="#D8D8D8"
2025-08-13 11:10:19 +08:00
>
<swiper-item
v-for="(item, index) in bannerList"
:key="index"
@click="onBannerClick(item, index)"
>
2025-08-22 17:27:58 +08:00
<image :src="item.image"></image>
2025-08-13 11:10:19 +08:00
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
name: 'BannerSwiper',
props: {
bannerList: {
type: Array,
default: () => [],
},
indicatorDots: {
type: Boolean,
default: true,
},
autoplay: {
type: Boolean,
default: true,
},
interval: {
type: Number,
default: 2000,
},
duration: {
type: Number,
default: 500,
},
},
methods: {
onSwiperChange(e) {
this.$emit('change', e.detail.current)
},
onBannerClick(item, index) {
this.$emit('banner-click', { item, index })
},
},
}
</script>
<style lang="scss" scoped>
.banner-section {
2025-08-22 18:22:15 +08:00
display: flex;
justify-content: center;
width: 100%;
2025-08-13 11:10:19 +08:00
}
2025-08-22 18:22:15 +08:00
.swiper {
padding: 30rpx 0;
2025-08-22 18:40:51 +08:00
height: 400rpx;
2025-08-22 18:22:15 +08:00
width: 750rpx !important;
2025-08-20 13:57:52 +08:00
overflow: hidden;
2025-08-22 17:27:58 +08:00
2025-08-13 11:10:19 +08:00
/* 通用指示器样式 - 覆盖所有可能的类名 */
:deep([class*='swiper-dot']) {
border-radius: 50% !important;
transition: all 0.3s ease !important;
}
.swiper-item {
display: block;
line-height: 300rpx;
text-align: center;
}
2025-08-22 18:40:51 +08:00
image {
width: 750rpx !important;
height: 100% !important;
}
2025-08-13 11:10:19 +08:00
}
</style>