<template>
    <div>
    <div class='list gap-x-2.5 gap-y-1 flex items-center flex-wrap'>
        <div v-for="(url, index) in imgList" :key="index" @click='toPreview(index)'>
            <img style='width: 1.47rem;height: 2.04rem'  :src="url.trueDownloadUrl" />
        </div>
    </div>
        <van-overlay :show='imgShow' @click='imgShow = false'>
            <div class='wrapper'>
                <van-swipe  class='block' :initial-swipe='initSwipe'>
                    <van-swipe-item v-for='image in imgList' :key='image'>
                        <img :src='image.trueDownloadUrl' style='width: 100%;height: 100%'/>
                    </van-swipe-item>
                </van-swipe>
            </div>
        </van-overlay>
    </div>
</template>

<script>
export default {
    name: 'imagePreview',
    props: {
        imgList: Array,
    },
    data() {
        return {
            imgShow: false,
            initSwipe: 0
        }
    },
    methods: {
        //图片预览
        toPreview(index) {
            this.initSwipe = index
            this.imgShow = true
        },
    }
}
</script>

<style scoped lang='less'>
.wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    .block {
        width: 100%;
    }
}
</style>