uniapp滚动消息列表

两个相同的循环列表,循环滚动

html 复制代码
<view class="winners_list uni-flex uni-column" :animation="animationData">
												<view v-for="(item, index) in winnersList" :key="index" class="li uni-flex uni-column">
													<img :src="item.img" alt="" />
													<view>
														<div class="info">
															<span>
																<text>{{ item.info }}</text>
															</span>
															<span>
																<text>{{ item.date }}</text>
															</span>
														</div>
														<div class="prize_name">
															<text>{{ item.prize }}</text>
														</div>
													</view>
												</view>
											</view>
											<view class="winners_list uni-flex uni-column" :animation="animationData">
												<view v-for="(item, index) in winnersList" :key="index" class="li uni-flex uni-column">
													<img :src="item.img" alt="" />
													<view>
														<div class="info">
															<span>
																<text>{{ item.info }}</text>
															</span>
															<span>
																<text>{{ item.date }}</text>
															</span>
														</div>
														<div class="prize_name">
															<text>{{ item.prize }}</text>
														</div>
													</view>
												</view>
											</view>
javascript 复制代码
   //滚动 
			getHeight(Class) {
				let query = uni.createSelectorQuery().in(this);
				query
					.selectAll(Class)
					.boundingClientRect(data => {
						this.height = data[0].height;
					})
					.exec();
			},
			prizeScroll() {
				let speed = 50;
				let animation = uni.createAnimation({
					duration: this.getHeight('.winners_list') / speed,
					timingFunction: 'linear',
					delay: 0
				});
				this.animation = animation;
			this.timer=setInterval(() => {
				console.log('123');
					if (this.scrollHeight >= this.height) {
						this.stopScroll()
						this.prizeScroll()
					} else {
						this.scrollHeight = this.scrollHeight + 1;
						animation.translateY(-this.scrollHeight).step();
						this.animationData = animation.export();
					}
				}, speed);
			},
			
			// 停止动画
			stopScroll(){
				if(this.timer){
					clearInterval(this.timer)
				}
				this.animation.translateY(0).step();
				this.scrollHeight = 0;
				this.animationData = this.animation.export();
			},
			
			
			
			taBtn(index){
				this.currentIndex=index;
				if(index==1){
					this.$nextTick(()=>{
							this.prizeScroll();
					})
				}else{
					this.stopScroll()
				}
			}
相关推荐
蓝色心灵-海1 分钟前
小律书 技术架构详解:前后端分离的自律管理系统设计
java·http·小程序·架构·uni-app
陆枫Larry3 分钟前
用 Git 别名(Alias)简化日常操作
前端
阿泽·黑核6 分钟前
Easy Vibe Coding 学习心得(三):前端之美——从设计稿到精美界面
前端·vibe coding·easy vibe
无心水15 分钟前
【时间利器】4、JavaScript时间处理全解:Date/moment/dayjs/Temporal
开发语言·前端·javascript·状态模式·openclaw·date/moment·dayjs/temporal
踩着两条虫20 分钟前
AI 驱动的 Vue3 应用开发平台 深入探究(二十五):API与参考之Renderer API 参考
前端·vue.js·人工智能
踩着两条虫21 分钟前
AI 驱动的 Vue3 应用开发平台 深入探究(二十四):API与参考之Provider API 参考
前端·vue.js·ai编程
恋猫de小郭27 分钟前
Android Studio Panda 2 ,支持 AI 用 Vibe Coding 创建项目
android·前端·flutter
爱学习的程序媛29 分钟前
【Web前端】WebSocket 详解
前端·websocket·网络协议·web
BJ-Giser29 分钟前
Cesium夜晚月亮银河夜空效果
前端·可视化·cesium
happymaker062630 分钟前
web前端学习日记——DAY06(js基础语法与数据类型)
前端·javascript·学习