Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vue dynamic component props

//--- html
<component 
    v-for="(comp, index) in dynamic" 
    :key="index"
    :is="comp.component" 
  	v-bind="{...comp.props}" />


//--- script vue
import component1 from 'component1';
import component2 from 'component2';

export default {
	components: {
      component1,
      component2
    },
	data(){
		return {
    		dynamic: [
            	{ 
                	component: 'component1',
                    props: {foo: bar, ...}
             	},
                { 
                	component: 'component2',
                    props: {foo: bar, ...}
             	},
         	]
    	}
	}
}
 
PREVIOUS NEXT
Tagged: #vue #dynamic #component #props
ADD COMMENT
Topic
Name
4+7 =