Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

380
Views
Vue.js - Why is my parent component being mounted before the child component is mounted?

I'm using Nuxt version 2.15.7 and Vue 2.6.14. My understanding is that child components are mounted before the parent component is mounted, as explained in this answer.

However, in my project I'm experiencing the opposite:

Parent.vue

<template>
    <div class="parent">
        <MessageCard ref="messageCard"></MessageCard>
    </div>
</template>

<script>
export default {
    mounted() {
        console.log("Parent Mounted");
        console.log(this.$refs.messageCard); // undefined
    }
}
</script>

MessageCard.vue

<template>
    <div class="messageCard">Hello</div>
</template>

<script>
    export default {
        mounted() {
            console.log("Child mounted");
        }
    }
</script>

The output on my console shows:

Parent mounted
undefined
Child mounted

enter image description here

According to the vue forum Shouldn't the child component be mounted before the parent? I need to call methods on the child, but it's undefined. I've even tried this.$nextTick(), only to find the same results. I understand the resources I linked to are from 2018 and 2017 respectively... has this behavior changed in the last 4 years?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!