uni-app卡片式轮播

uni-app卡片式轮播

<template>
	<uni-swiper-dot :info="info" :current="current" :mode="mode" :dots-styles="dotsStyles" field="content">
		<swiper class="swiper-box" @change="change" :autoplay="true" :interval="1000">
			<swiper-item v-for="(item, index) in info" :key="index">
				<view :class="item.colorClass" class="swiper-item">
					<image class="image" :src="item.url" mode="aspectFill" />
				</view>
			</swiper-item>
		</swiper>
	</uni-swiper-dot>
</template>
<script>
	// import uniSwiperDot from '@/components/uni-swiper-dot/uni-swiper-dot.vue'
	export default {
		data() {
			return {
				info: [{
						colorClass: 'uni-bg-red',
						url: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/shuijiao.jpg',
						content: '内容 A'
					},
					{
						colorClass: 'uni-bg-green',
						url: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/muwu.jpg',
						content: '内容 B'
					},
					{
						colorClass: 'uni-bg-blue',
						url: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/cbd.jpg',
						content: '内容 C'
					}
				],
				current: 0,
				mode: 'default',
				dotsStyles: {}//为空是加载默认的模式
			}
		},
		onLoad() {

		},
		methods: {
			change(e) {
				this.current = e.detail.current
			},
		}
	}
</script>
<style>
	.image {
		width: 750rpx;
		height: 400upx;
	}

	.swiper-box {
		height: 200px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: #999;
		color: #fff;
	}
</style>



上一篇:html2canvas 轮播保存每个图片内容


下一篇:小程序swiper怎么点击跳转页面