[Vuejs]-Vuejs child component lifecycle diffrence root component?

0👍

It should work normally as other lifecycle methods. I’ve retested your case (based on vue cli webpack template) and it’s working fine. Are you using vue-cli or custom bundle / build way?

Please, see my example below (I guess you miss comma after lifecycle method curly bracket):

<script>
  // PARENT component
  import Child from './components/Child'

  export default {
    name: 'parent',

    components: {
     Child
    }
 }
</script>


<script>
  // CHILD component
  export default {
    name: 'child',

    beforeMount () {
     console.log('before mount')
    },

    created () {
      console.log('created')
    },
    beforeCreate () {
      console.log('before create')
    }
 }
</script>

Leave a comment