Home > Software design >  onActivated wont trigger in Quasar (vue3) component
onActivated wont trigger in Quasar (vue3) component

Time:11-22

For some reason the onActivated function in vue3 wont trigger and cannot figure out why. It is not the first time I am implementing this but for some reason nothing happens. I am using vue 3.0.0. Here is my code and component

Index.vue

<template>
  <MyComp />
</template>

<script setup>
import MyComp from "../components/MyComp.vue";
</script>

MyComp.vue

<template>
  <div>{{ el }}</div>
</template>

<script setup>
import { ref, onMounted, onActivated } from "vue";

const el = ref("Hello");

onMounted(() => {
  console.log("onMounted");
});
onActivated(() => {
  console.log("onActivated");
});
</script>

CodePudding user response:

onActivated only triggers for components inside a KeepAlive tag, but you don't have any KeepAlive tags in the code you posted, so onMounted should be all you need. See https://vuejs.org/api/composition-api-lifecycle.html#onactivated

  • Related