用css控制并动态绑定class名来实现,在遮罩层打开的时候css样式也开启,关闭时css样式失效
<view class="my" @touchend="end" @touchmove="move" :class="{popupShow:popupShow}"><u-popup :show="popupShow" mode="right" @close="closeMenu" bgColor="#161823" safeAreaInsetTop></u-popup><u-button type="primary" class="top-right-btn" @click="openMenu">开启遮罩层</u-button>
</view>
<script>
export default {data() {return {popupShow:false;}}methods:{openMenu() {this.popupShow = true;}closeMenu() {this.popupShow = false;}}
</script>
<style lang="scss" scoped>
.popupShow {overflow: hidden;position: fixed;
}
</style>