Skip to content

Instantly share code, notes, and snippets.

@Gregg
Created October 11, 2018 14:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gregg/82a1e8410ee43d924e7e9f61b0512e45 to your computer and use it in GitHub Desktop.
Save Gregg/82a1e8410ee43d924e7e9f61b0512e45 to your computer and use it in GitHub Desktop.
Example of how to clear a timeout on beforeDestroy
var Component = {
mounted() {
this.setTimeOutClose()
},
beforeDestroy() {
clearTimeout(this.timeout);
},
data() {
return {
timeout: null
};
},
methods: {
setTimeOutClose() {
this.timeout = setTimeout(function () {
console.log("Did something");
}, 1000);
}
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment