您当前的位置: 首页 >  cmmboy1990

uniapp scroll-view横向滚动 自定义底部指示器样式

cmmboy1990 发布时间:2021-09-24 14:15:43 ,浏览量:4

uniapp scroll-view横向滚动 自定义底部指示器样式 1.效果 在这里插入图片描述2.思路:动态设置元素的margin

3.代码


	
		
			
				
			

		
		

		
			
		
	



	export default {
		data() {
			return {
				imageList: [1, 2],
				progressMargin:0
			}
		},
		methods: {
			scroll(event) {
				//
				console.log("距离每个边界距离" + event.detail.scrollWidth);
				console.log("距离x距离" + event.detail.scrollLeft);
				var num1 = event.detail.scrollWidth / 2
				var num2 = event.detail.scrollLeft
				var p = (num2 / num1) * 100;
				
				this.progressMargin = Math.round(p)-10;
				console.log("percent==>" + this.progressMargin);
				if (this.progressMargin 99) {
					this.progressMargin = 90;
				}
				// if (p >=100) {
				// 	this.progressMargin = 80;
				// }
			},
		}
	}



	
	.progressAction{
		width: 10%;
		height: 15rpx;
		border-radius: 20rpx;
		background-color: #FF7C0E;
	    /* margin-left: 50%; */
	}
	.progressBg {
		width: 100%;
		height: 15rpx;
		border-radius: 20rpx;
		background-color: #999999;

	}

	.images-view {
		width: 100%;
		overflow: hidden;
		white-space: nowrap;
		margin-top: 10rpx;
		margin-bottom: 10rpx;
	}

	.images-view-item {
		display: inline-block;
		width: 100%;
		/* margin-right: 20rpx; */
	}


4.解释:this.progressMargin = Math.round§-10;减去10 是 .progressAction width: 10%; 减去的是指示器的宽度10%

关注
打赏
1688896170
查看更多评论

cmmboy1990

暂无认证

  • 4浏览

    0关注

    131博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0502s