uniapp实现小红书登陆页面背景图无限滚动效果

<template>
	<view class="uni-navbar">
		<view class="img"  :style="'top:'+top+'rpx'">
			<image  @load="loads" :style="'height:'+height+'rpx'" src="../../../static/login/1.png" mode="" />    
			<image   :style="'height:'+height+'rpx'" src="../../../static/login/1.png" mode="" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				top: 0, //张图片的向上偏移
				height: 0, //图片原始高度
			}
		},
		methods: {
			//图片初始化函数
			loads(res) {
				this.height = res.detail.height
				this.top = res.currentTarget.offsetTop
				setInterval(item => {
					this.top--
					if (this.top == -this.height) {
						this.top = res.currentTarget.offsetTop
					}
				},1)
			},
		},
	}
</script>

<style>
	.img {
		display: flex;
		flex-direction: column;
		width: 100%;
		position: fixed;
	}

	.img>image {
		width: 100%;
	}
	.uni-navbar {
		padding-top: var(--status-bar-height); //适应不同手机屏幕的通知栏高度
	}
</style>

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值