<div ref="dialog" class="dialog">
内容
</div>
.dialog {
width: 100%;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 100;
box-sizing: border-box;
overflow: hidden;
}
methods: {
closeDialog () {
this.$emit('closeDialog')
},
// 阻止滚动
stopScroll () {
let dialogEl = this.$refs['dialog']
dialogEl.addEventListener('touchmove', (e) => {
e.preventDefault()
})
}
},
mounted () {
// 阻止滚动
this.stopScroll()
}