Created
October 11, 2018 14:53
-
-
Save Gregg/82a1e8410ee43d924e7e9f61b0512e45 to your computer and use it in GitHub Desktop.
Example of how to clear a timeout on beforeDestroy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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