【uni-app 一个能自动播放,有指示点的轮播图怎么写】

uni-app 轮播图怎么写

轮播图在uni里有自己的标签,改里面的属性跟改自己写的组件属性一样。如何写组件链接

一个写好的轮播图效果图如下,这个轮播图有指示点,能自动播放
在这里插入图片描述

·要了解轮播图的属性可以点击此链接去官方文档查看详情,我修改的属性依次是是否有指示点,指示点颜色,选中指示点的颜色,是否自动播放,自动播放毫秒数,切换时间
<template>
	<view>
		<swiper class="swiper" 
		:indicator-dots='true' 
		indicator-color="#fff" 
		indicator-active-color='#ccc'
		:autoplay='true'
		 :interval='3000' 
		 :duration='300' 
		 style="padding: 0rpx 24rpx;">
		 <!-- 不需要循环直接手动放图片 -->
		 <swiper-item>
		 	<view class="img">
		 		<image src="../../../static/img/png/boy1.png" mode=""></image>
		 	</view>
		 </swiper-item>
		 
		 <!-- 循环方便点 -->
			<swiper-item v-for="(item,index) in swiper_img" style="height: 300rpx;">
				<view class="img">
					<image :src="item.src" mode=""></image>
				</view>
			</swiper-item>

		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiper_img:[
					{name:"12f3",src:"../../../static/img/boy2.jpg"},
					{name:"12s3",src:"../../../static/img/boy2.jpg"},
					{name:"12fd3",src:"../../../static/img/boy3.jpg"},
				]
			}
		},
		methods: {
			
		}
	}
</script>

<style scoped>
	.img{
		width: 100%;
		height: 100%;
	}
	image{
		width: 100%;
		height: 100%;
	}
</style>

自动播放和前后衔接是会冲突的,二者只能选一

在首页放个纯图片的轮播图写起来还是很简单滴,不点个赞再走吗在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/TChildeSeven/article/details/107566158
今日推荐