123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <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" :style="imgFit" />
- </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,
- },
- fit: {
- type: String,
- default: 'cover',
- },
- },
- data() {
- const swiperOption = {}
- swiperOption.autoplay = this.autoplay
- swiperOption.loop = this.loop
- if (this.pagination) {
- swiperOption.pagination = {
- el: '.swiper-pagination',
- clickable: true,
- }
- }
- return {
- swiperOption,
- }
- },
- computed: {
- imgFit() {
- return {
- 'object-fit': this.fit,
- }
- },
- },
- }
- </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>
|