uniapp 实现图片自动纵向轮播

✴️星光不负赶路人,所有的幸运都来自于坚持不懈的努力,大家一起加油吧

问题:uniapp 实现图片自动纵向轮播

直接上代码

<template>
	<view class="login-box" v-show="iSif">
		<view class="broadcastTopBtm"
			:style="'height:'+height+'rpx;--scrollHeight--:'+ (-height)+'rpx;--scrollSpeed--:'+ 6 +'s;'"  >
		 备注:	--scrollSpeed-- 这个就是在运行在多长时间内执行完这个动画 (这个看自己需求)
			<view class="animation_pausedcss" :class="iSif ? 'broadcastDataTopBtmDatacss_top' :''"
				:style="'height:'+height+'rpx;'">
				<view class="roll_list " :style="'height:'+height+'rpx;'" v-for="(item,index) in rollList" :key="index">
					<image :src="item.img" :style="'height:'+height+'rpx;'" @load="loads" mode=""></image>
				</view>
			</view>
		</view>
		
	</view>
</template>

js

/**
在这里解释一下,为什么要v-show,在苹果系统里面(其他手机可正常显示) ,load函数执行 比scrollHeigh 传的慢,导致,height一直为0,所以需要加这个哦
**/
     data() {
			return {
				rollList: [{
						img: 图片地址
					},

					{
						img: 图片地址
					}
				],
				height: 0,
				iSif: false
			}
		},
		methods: {
	      	loads(res) {
			    	this.height = res.detail.height;
				   this.iSif = true;
			    }
		}

css

这个是less的写法.sass写法需要将@改为$
@scrollHeight: var(--scrollHeight--);

	@keyframes around_top {
		0% {
			top: 0%;
		}

		100% {
			top: @scrollHeight;
		}
	}
		.login-box {
		width: 100%;
		height: 100%;
		position: relative;

		.broadcastTopBtm {
			position: fixed;
			height: 100%;
			width: 100%;

			.broadcastDataTopBtmDatacss_top {
				width: 100%;
				height: 100%;
				animation-name: around_top;
				animation-duration: var(--scrollSpeed--);
				animation-iteration-count: infinite;
				animation-timing-function: linear;
				position: absolute;
				left: 0;
				top: 0;

				.roll_list {
					display: flex;
					align-items: center;
					height: 100%;
					width: 100%;
					vertical-align: bottom;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陌寒1024

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值