HomeBanner.vue
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
<section class="home-banner">
<van-swipe class="banner-swiper" :autoplay="autoplay" lazy-render @change="handleChange">
<van-swipe-item class="swiper-item" v-for="(item, idx) in banners" :key="idx">
<img v-if="item.imgUrl" class="banner-img" :src="item.imgUrl" @click="handleItem(item)" />
<div v-else class="banner-img white">
<div class="banner-img skeleton"></div>
</div>
</van-swipe-item>
<template #indicator>
<div class="nafmii-indicator">
<span class="indicator-item" :class="{'indicator-active': active == idx}" v-for="(item, idx) in banners" :key="idx" />
</div>
</template>
</van-swipe>
</section>
</template>
<script>
export default {
name: 'HomeBanner',
props: {
},
data () {
return {
autoplay: 5000,
active: 0,
banners: [
{},
{}
]
}
},
methods: {
handleItem (banner) {
},
handleChange (index) {
this.active = index
}
}
}
</script>
<style lang="less" scoped>
.white {
background: #eee;
}
@PaddingSize: 15;
.home-banner {
margin-top: @PaddingSize;
.banner-swiper {
.banner-img {
height: 145px;
border-radius: 5px;
width: 100%;
}
@PointSize: 5px;
.nafmii-indicator {
position: absolute;
left: 0;
bottom: 10px;
right: 0;
display: flex;
align-items: center;
justify-content: center;
height: @PointSize;
.indicator-item {
background: rgba(255, 255, 255, 0.4);
width: @PointSize;
height: @PointSize;
border-radius: calc(@PointSize / 2);
margin: 0 4px;
&.indicator-active {
background: white;
width: 21.5px;
}
}
}
}
}
</style>