English
Lifecycle Hooks
By webfansplz @webfansplz
For this challenge, you'll use the Composition API: Lifecycle Hooks
to complete the challenge. Here's what you need to implement 👇:
// Child.vue
<script setup lang="ts">
import { onMounted, inject } from "vue"
const timer = inject('timer')
const count = inject('count')
onMounted(() => {
// The timer will work abnormally when the child component is toggled. Lets fix it.
timer.value = window.setInterval(() => {
count.value++
}, 1000)
})
</script>
<template>
<div>
<p>
Child Component: {{ count }}
</p>
</div>
</template>