How to check if child component is mounted in vue?
10:16 09 Nov 2022

I want to check if child component is mounted and I want to move that information to he parent component. For this I am using emits. So with example here is my parent component:



export default {
  data() {
    return {
      childMounted: false,
    };
  },

  mounted() {
    if (this.childMounted) {
      //do something
    }
  },
}

and in child component, I am changing 'is-child-mounted' to true:

mounted() {
    this.$emit('isChildMounted', true);
  },

But still if (this.childMounted) comes false. So how can I check in parent component if the child component is mounted?

vue.js vuejs2 vue-component vuejs3 emit