Skip to content

10 - Lifecycle Hooks #2866

Open
Open
@geek4ctrl

Description

@geek4ctrl
// your answers
<script setup lang="ts"> import { onUnmounted } from "vue"; import { onMounted, inject } from "vue" const timer = inject("timer") const count = inject("count") onMounted(() => { timer.value = window.setInterval(() => { count.value++ }, 1000) }) onUnmounted(() => { clearInterval(timer.value) }) </script>

Child Component: {{ count }}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions