uniapp自定义蒙层弹窗列表 滑动 底层div也会滑动 取消底层滑动

这篇文章展示了在Vue.js应用中如何使用`@touchmove.stop.prevent`指令来阻止父级页面的滚动条,并结合`scroll-view`组件以及`scroll-y=true`属性实现在弹窗内部的滚动。`touchstart`,`touchmove`和`touchend`事件被用来处理拖拽功能,同时提供了打开和关闭弹窗的方法。
摘要由CSDN通过智能技术生成

采用**@touchmove.stop.prevent=“moveHandle”** 阻止父级 页面 滚动条
另弹窗中需要配合 scroll-view scroll-y=“true” class=“scroll-view” 方可滚动 注意添加 “scroll-y=“true””

<view class="popmeng" @tap.stop="stopPop" id="bt" :class="show?'popmeng1':''" >
			<view class="addpop" @tap.stop="" id="addpop" :class="show?'showpop':''" @touchmove.stop.prevent="moveHandle">
				<!-- 拖拽 -->
				<view class="btnpop-box" @touchend='touchend' @touchmove="touchmove($event)"
					@touchstart="touchstart($event)">
					<view class="drag">
					</view>
				</view>
				<view class="pop-tit">
				{{showType==1?'全部藏品':'正在寄售'}}
					<view class="pop-tit-line" >
					</view>
				</view>
				<view class="pop-content">
					<template v-if="lists.length>0">
					<scroll-view scroll-y="true" class="scroll-view">
						<view class="pop-list" v-for="(item,index) in lists" :key="index" @click.stop="goDetail(item.id)">
							<view class="poplist-left">
								<img :src="item.image" alt="">
							</view>
							<view class="poplist-right">
								<view class="pop-list-content">
									<view class="pop-list-tit">
										{{item.name}}
									</view>
									<view class="pop-list-nums-box">
										<view class="pop-list-num" v-if="item.goods_number_new">
											#{{item.goods_number_new}}
										</view>
										<view class="pop-list-nums" v-if="showType == 2">
											{{item.price}}元
										</view>
									</view>
									
								</view>
								<view class="pop-radio" @tap.stop="shangjia(item.id,item.name,1)" v-if="showType == 1">
									<img src="../../assets/shangjia.png" alt="">
								</view>
								<view class="pop-radio" @tap.stop="shangjia(item.id,item.name,2)" v-if="showType == 2">
									<img src="../../assets/xiajia.png" alt="">
								</view>
								<view class="pop-radio" @tap.stop="shangjia(item.id,item.name,3)" v-if="showType == 2" style="margin-left: 48rpx;">
									<img src="../../assets/gaijia.png" alt="">
								</view>
							</view>
						</view>
					</scroll-view>
						
					</template>
				</view>
				<view class="pop-btn-box" style="z-index: 50;">
					<!--  -->
					<view class="pop-btn-submit1" @tap="allshangjia(lists[0].name,4)" v-if="showType==1">
						全部上架
					</view>
					<view class="pop-btn-submit1" @tap.stop="allxiajia()" v-else>
						全部下架
					</view>
				</view>
			</view>
		</view>
<script setup>
	export default {
		data() {
			return {
			show:false;
			}
		},
		methods: {
			// 打开弹窗
			add() {
					this.show = true //打开弹窗
			},
			// 关闭弹窗index
			stopPop() {
				this.$nextTick(() => this.show = false);
			},
			//
			moveHandle(){
				return false;
			},
		}
	}
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值