Answer the question
In order to leave comments, you need to log in
VueJs How to call a modal window once a day?
Good afternoon)
Help please. How to make the modal window pop up when loading the site once a day.
<div v-if="isShow">
<div class="modal-mask" >
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-body">
<slot name="body">
<img src="./assets/image/picture.jpg" alt="">
</slot>
</div>
<div class="modal-footer">
<slot name="footer">
<button class="modal-default-button" @click="close"> Кнопка 1</button>
<button class="modal-default-link" @click="close">Кнопка 2</button >
</slot>
</div>
</div>
</div>
</div>
</div>
<script>
export default {
name: 'app',
data() {
return {
isShow: true,
}
},
mounted () {
this.runModalTimer()
this.setDevHoursModal()
},
methods: {
close(){
this.isShow = false;
},
runModalTimer () {
setTimeout(() => {
this.isShow = true
}, 4000)
},
setDevHoursModal() {
if (localStorage) {
let nextPopup = localStorage.getItem('isShow');
if (nextPopup > new Date()) {
return (this.isShow = true); // let's be a little more explicit here
}
let expires = new Date();
expires = expires.setHours(expires.getHours() + 24);
localStorage.setItem('isShow', expires);
return false;
}
return true;
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question