+1 vote
in VueJS by
Why do you need local registration?

1 Answer

0 votes
by

Due to global registration, even if you don't use the component it could still be included in your final build. So it will create unnecessary javascript in the application. This can be avoided using local registration with the below steps,

First you need to define your components as plain JavaScript objects

var ComponentA = { /* ... */ }

var ComponentB = { /* ... */ }

var ComponentC = { /* ... */ }

Locally registered components will not be available in sub components. In this case, you need to add them in components section

var ComponentA = { /* ... */ }

var ComponentB = {

  components: {

    'component-a': ComponentA

  },

  // ...

}

You can use the components in the components section of the vue instance,

new Vue({

  el: '#app',

  components: {

    'component-a': ComponentA,

    'component-b': ComponentB

  }

})

...