Check out my scenario on jsBin
In my setup, I have a selector
<component :is="selectedComponent"></component>
, along with a <select v-model="currentComponent">...</select>
that allows me to choose which one is displayed.
Currently, I am managing a separate list of components structured like this:
var componentList = [
{ name: 'Component A', id: 'component-a' },
{ name: 'Component B', id: 'component-b' }
];
This approach feels repetitive as I have to update this list each time a new component is added. I would prefer a more elegant way to abstract the component list.
I attempted the following in my app:
var vm = Vue.extend({
components: {
'component-a': ComponentA,
// and so on...
}
computed: {
componentList: function() {
// possibly map this.$options.components or another method?
}
}
});
However, I haven't made much progress. Any suggestions, best practices, or tips are greatly appreciated!
Thank you!