uni-app中scroll-view的高度

点击弹出滚动列表模态框
本文介绍如何使用uni-app实现一个可点击弹出并带有下拉滑动功能的模态框,详细展示了代码实现过程及样式设置,包括如何通过uni.getSystemInfo和uni.createSelectorQuery动态设置scroll-view高度。

需要做一个点击弹出列表的模态框,这个列表可以下拉滑动

1、代码

<view @tap="showModal=true">{{form.organizationName}}</view>
<view class="moddal" v-if="showModal" @tap="showModal=false">
				<view class="moddal-content">
					<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" :style="{height:500+'rpx'} ">
					    <view class="list" v-for="(item, ind) in list" :key="ind"  @tap.stop="isCheckCustomer(item, ind)">
					    	<text class="t-icon ischeck" :class="selectIndex == ind ?'iconfuxuan--2': 'iconfuxuan--1'"></text>
					    	<view class="list-content">{{item.name}}</view>
					    </view>
					</scroll-view>
					
				</view>
			</view>

在这里,我给scroll-view设置的固定的高度,如果想给它设置动态高度,需要调用uni.getSystemInfo(OBJECT),可以获取屏幕高度,uni.createSelectorQuery(),获取节点距离顶部的高度

 

样式

.moddal{
		position: fixed;
		left: 0;
		bottom: 0;
		right: 0;
		top:0;
		background-color: rgba(0,0,0,.5);
		//height: 500rpx;
		z-index: 10;
	
		.moddal-content{
			padding: 30rpx;
			background-color: #FFFFFF;
			position: fixed;
			bottom: 0;
			.list{
				position: relative;
				display: flex;
				margin-bottom: 40rpx;
				align-items: center;
				.ischeck{
					width: 30rpx;
					height: 30rpx;
				}
				.list-content{
					padding-left: 20rpx;
					color: #333333;
					flex: 1;
				}
			}
		}
		
	}

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

LLL_LH

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

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

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

打赏作者

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

抵扣说明:

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

余额充值