TommyD
TommyD

Reputation: 1043

Multiple imports with vue

I have about 20 forms which get switched using a dynamic component

 <component v-bind:is="activeForm"></component

Rather than have about 20 of these

 import Concentform from '../forms/concentForm'

and 20 declarations

export default {
  components: {
     Concentform,
     anotherForm,
     moreForms,
 }
}

Can I do a mass import?

Upvotes: 0

Views: 515

Answers (1)

Emīls Gulbis
Emīls Gulbis

Reputation: 2070

  1. Add index.js under ../forms with

    import Concentform from './concentForm'
    export default {
        Concentform
    }
    
  2. Import all in once (default) import forms from '../forms/'

  3. Set components
export default {
  components: {
     ...forms,
     otherComponent
  }
}

Upvotes: 3

Related Questions