watch: {
checkBlackoutState() {
if (this.isModalAddVisible || this.activeId) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}
},
},
.no-overflow {
overflow: hidden;
}
mounted() {
this.$watch(
() => this.isModalAddVisible || this.activeId,
val => document.body.classList.toggle('no-overflow', val),
{ immediate: true }
);
},
export default {
data() {
return {
isModalAddVisible: false,
activeId: null,
};
},
watch: {
isModalAddVisible(newValue) {
if (newValue || this.activeId) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}
},
activeId(newValue) {
if (this.isModalAddVisible || newValue) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}
},
},
};