beforeUnmount Before Unmount
Last updated: 2026-10-22
beforeUnmount Before Unmount
beforeUnmount runs just before the instance is destroyed — the DOM is still intact, the moment to clean up timers and listeners.
| Group | Options: Rendering & Lifecycle |
|---|---|
| Kind | Option |
| Scope | Component |
| Vue Version | 3.0+ |
| SSR Support | Yes |
📝 Syntax
export default {
beforeUnmount() {
clearInterval(this.timer)
}
}
⚙️ Arguments
| value | No arguments |
|---|
Returns:No return value
▶ Example
Edit the code below and see the live result:
Output:
Toggling off logs 'timer cleared'.
💡 Key Points
💡 Tip Cleanup checklist: timers, listeners, sockets, third-party destroy().
ℹ️ Note The DOM still exists — finish DOM-dependent teardown here.
⚠️ Warning Deactivation under KeepAlive does not fire unmount hooks.
🏷️ Related Rendering & Lifecycle
💡 Related Cases
More case studies coming soon.
📚 Related Tutorials
❓ FAQ
Q How does it split with unmounted?
A DOM-dependent cleanup here; pure logic either place.
Q What if I forget?
A Leaked timers and listeners keep running.
Q Can unmount be cancelled?
A No — use v-if.