title: problems with clearTimeout() in vue.js
body: <p>i'm doing a shopping cart in vue but i'm having some issues. having never used the library i'm probably doing basics wrong, but:</p>
  
  <p>when I add something to the cart I have an <code>onclick</code> function, <code>expander(item)</code> which looks like this:</p>
  
  <pre><code>this.addToCart(item);
  this.show = true;           
  clearTimeout(this.timer);
  timer: setTimeout(()=&gt;{ this.show = false; }, 3000);    
  </code></pre>
  
  <p>so what it does it adds to cart, sets the visibility of the cart div to true, then after a delay of three seconds it sets the cart div back to false.</p>
  
  <p>the thing is, the clearTimeout(this.timer) doesn't work. so for each click, after three seconds, no matter what I do it sets the visibility back to false. what I'm trying to do with this function is to reset the timer each time and after reading up it seems like I'm doing it the correct way.</p>
  
  <p>so, I'm guessing my problem is that i need to declare the variable 
  <code>timer: setTimeout(()=&gt;{ this.show = false; }, 3000);</code>
   outside of the function, in order for clearTimeout() to find it at the beginning of my function. my problem here is that wherever I declare it, it can't seem to find it. I've tried declaring the variable in my <code>data {}</code> and also outside of the Vue instance but it doesn't seem to want to find it in my functions.</p>
  
  <p>so: how do I declare the variable? is that even my problem? is there may be an easier fix for this than what it's trying to do?</p>
  
  <p>thanks!</p>