1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <template>
- <swiper class="swiper simple-swiper" :options="swiperOption">
- <swiper-slide v-for="(item, index) in imageList" :key="index">
- <div class="slide-content"><img :src="item" class="slide" /></div>
- </swiper-slide>
- <div class="swiper-pagination" slot="pagination"></div>
- </swiper>
- </template>
- <script>
- import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
- import swiper from 'swiper'
- export default {
- name: 'simple-swiper',
- components: {
- Swiper,
- SwiperSlide,
- },
- props: {
- imageList: {
- type: Array,
- default: () => [],
- },
- autoplay: {
- type: Boolean,
- default: true,
- },
- pagination: {
- type: Boolean,
- default: true,
- },
- loop: {
- type: Boolean,
- default: true,
- },
- },
- data() {
- const swiperOption = {}
- swiperOption.autoplay = this.autoplay
- swiperOption.loop = this.loop
- if (this.pagination) {
- swiperOption.pagination = {
- el: '.swiper-pagination',
- clickable: true,
- }
- }
- return {
- swiperOption,
- }
- },
- }
- </script>
- <style scoped lang="scss">
- .simple-swiper {
- height: 100%;
- ::v-deep {
- .swiper-pagination-bullet-active {
- background: #535353;
- }
- }
- .slide {
- display: block;
- width: 100%;
- object-fit: cover;
- }
- }
- </style>
|