I created a vue component, which has an initial ajax call that fetches an array of objects that i will be looping through. Is there a way to define/cast these objects as another vue component? This is what i got so far:
var myComponent = Vue.extend({
template: '#my-component',
created: function() {
this.$http
.get('/get_objects')
.then(function(data_array) {
for (var i = 0; i < data_array.data.length; i++) {
var item = data_array.data[i];
// <<-- How do i tell vue to cast another component type here??
}
}
);
}
});
Vue.component('my-component', myComponent);
new Vue({
el: 'body',
});
<child-component v-for="item in list"></child-component>vueway to do this, is to have previously defined your component, so you just populate it's data and display it withv-if/v-showif you have only one component to show or with av-forif you have many components to showitemvariable in the child component, when going with Josephs solution? It does not seem to be available in the child template.<tr is="child-component" v-for="item in list"></tr><tr is="child-component" v-for="item in list" :item="item"></tr>