Vue: Change class with the value of a variable in setInterval Vue: Change class with the value of a variable in setInterval vue.js vue.js

Vue: Change class with the value of a variable in setInterval


bind your function to the component...

 setInterval(function(){                 this.changeColor = !this.changeColor;                     }.bind(this), 2000);

and then you can do ...

<div id="effect" :class="[changeColor?'highlight':'shrink']"></div>