Answer the question
In order to leave comments, you need to log in
How to inherit value from methods in Vue?
<div @mouseenter="mouseEnter" @mouseleave="mouseLeave">
<h1>Hover me!</h1>
</div>
methods: {
mouseEnter() {
setInterval(function() {
console.log( "тик" );
}, 500);
},
mouseLeave() {
setTimeout(function() {
this.mouseEnter()
console.log( "достаточно" );
}, 1);
}
}
Answer the question
In order to leave comments, you need to log in
trying to stop the function
data: () => ({
intervalID: null,
}),
methods: {
mouseEnter() {
this.intervalID = setInterval(() => {
console.log('тик');
}, 500);
},
mouseLeave() {
clearInterval(this.intervalID);
this.intervalID = null;
},
},
mouseLeave() {
setTimeout(() => {
this.mouseEnter()
console.log( "достаточно" );
}, 1);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question