我创建了一个vue组件,它有一个初始的ajax调用,用于获取我将循环遍历的对象数组.有没有办法将这些对象定义/转换为另一个vue组件?这是我到目前为止所得到的:
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',
});
Run Code Online (Sandbox Code Playgroud)