在vuejs中附加json对象

时间:2017-10-03 13:45:36

标签: javascript arrays json javascript-objects

我有这个vue对象

var app = new Vue({
    el: '#app',
    data: {
            person:"",
            offset: 0,
            limit: 5
        },
        methods: {
            loadFirstSet: function() {
                getNewsJson(this.offset,this.limit,false);
            },
            loadMore: function() {
                this.offset += this.limit;
                getNewsJson(this.offset,this.limit,true);
            }
        }
    });

这是我从服务器获取更多数据的axios请求

function getNewsJson(offset,limit,append){
        axios.get(baseApi + 'all_person/' + offset + '/' + limit)
        .then(function(response) {
            if(response.data.status == true) {
                if(response.data.result.length > 0) {
                    if(append) {
                        a = app.person;
                        b = a.push(response.data.result);
                        console.log(b);
                    } else {
                        app.person = response.data.result;
                        console.log(response.data.result);
                    }
                }
            }
        })
        .catch(function(response) {

        });
    } 

我试图将新json对象附加到已存在的json对象,以包含加载更多的功能但是在执行此操作时,它无法正常工作,我该怎么办?附加json?

0 个答案:

没有答案