相关疑难解决方法(0)

VueJS嵌套组件

我创建了一个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)

javascript vue.js

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×1

vue.js ×1