-
-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Description
<script setup lang="ts">
import { onUnmounted, onMounted, inject } from "vue"
const timer = inject("timer")
const count = inject("count")
onMounted(() => {
timer.value = window.setInterval(() => {
count.value++
}, 1000)
})
onUnmounted(() => {
clearTimeout(timer.value)
count.value = 0
})
</script>
<template>
<div>
<p>
Child Component: {{ count }}
</p>
</div>
</template>