<template>
	
		<swiper 
		:interval="3000" 
		:duration="1000" 
		:indicator-dots="true" 
		:current="current" @change="swiperTab" 
		:autoplay="true"
		:circular="true"
		class="swiper"
		>
			<swiper-item v-for="(item,index) in dataList" :key="index">
				<image :src="item.url" class="swiper-img" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
</template>

<script>
	export default {
		name: "yf-carsousel",
		props:{
			imgList: {
				type: Array,
				default() {
					return []
				}
			}
		},
		data() {
			return {
				current: 0,
				dataList: []
			}
		},
		watch: {
			imgList: {
				handler(val) {
					console.log('watch....', val)
					this.dataList = val
				},
				deep: true
			}
		},
		mounted() {
			this.dataList = this.imgList
		},
		methods: {
			swiperTab(e) {
				var that = this;
				this.current = Number(e.target.current);
			}
		}
	}
</script>

<style>
	
	.swiper, .swiper-img {
		width: 100vw;
		height: 45vw;
	}
	
</style>
