本篇文章為大家展示了怎么在微信小程序中實現彈窗禁止頁面滾動功能,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
在小程序彈窗時,外部頁面禁止滾動, 可以在最外部容器設置catchtouchmove
但是如果彈窗內部也需要滾動,需要用scroll-view包裹,并設置scroll-ycatchtouchmove需要接收個方法,不然會一直警告
<view class="box">占位</view>
<view class="pop" catchtouchmove="touchMove">
<view class="popbg"></view>
<view class="popup">
<scroll-view scroll-y>
<view class="row" wx:for="{{10}}" wx:key="index">{{index}}</view>
</scroll-view>
</view>
</view>.box {
height: 120vh;
}
.popbg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
}
.popup {
position: fixed;
top: 20%;
left: 50%;
transform: translate(-50%, 0);
width: 70%;
background: #fff;
z-index: 1;
}
scroll-view {
height: 500rpx;
}
.row {
width: 100%;
height: 200rpx;
}Page({
touchMove() {
return
}
})上述內容就是怎么在微信小程序中實現彈窗禁止頁面滾動功能,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。