其他分享
首页 > 其他分享> > uni-app卡片式轮播

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>



标签:卡片式,cn,app,qiniu,jpg,content,uni,swiper
来源: https://blog.csdn.net/Wen_Tao98/article/details/116482304