1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <template>
- <view>
- <swiper :current="current" autoplay @change="onChange" :style="{height}">
- <swiper-item v-for="(item, index) in imgList" :key="index" class="banner-swipe">
- <image :src="item.imgPath" @click="onTap(item)"/>
- </swiper-item>
- </swiper>
- <view class="indication">
- <view :class="index === current? 'active':'default'" v-for="(item, index) in imgList" :key="index"></view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "banner",
- props: {
- imgList: Array,
- imageClass: String,
- height: String,
- },
- data() {
- return {
- current: 0,
- };
- },
- methods: {
- onChange(e){
- this.current = e.detail.current;
- },
- onTap(item) {
- this.$emit('banner',item);
- },
- }
- }
- </script>
- <style scoped>
- .banner-swipe {
- display: flex;
- justify-content: center;
- align-items: center;
- }
-
- .indication {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- margin-bottom: 10rpx;
- }
- .default {
- margin-right: 9rpx;
- width: 15rpx;
- height: 15rpx;
- background: #B9BBCD;
- border-radius: 15rpx;
- }
- .active {
- margin-right: 9rpx;
- width: 26rpx;
- height: 15rpx;
- background: #FF4330;
- border-radius: 7.5rpx;
- }
- </style>
|