Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 3.03 KB

File metadata and controls

36 lines (25 loc) · 3.03 KB

Lifecycle Hooks easy #Composition API #Lifecycle

By webfansplz @webfansplz

Take the Challenge    简体中文

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>

Back Share your Solutions Check out Solutions