首页 > vue.js resource 请求后台得到json要怎么解析出来?

vue.js resource 请求后台得到json要怎么解析出来?

new Vue({
    el: '#post_from2',
    ready: function () {
        this.$http.post('./fun/post.php', {
            type: "sydata"
        }, {
            headers: {
                "X-Requested-With": "XMLHttpRequest"
            },
            emulateJSON: true
        }).then(function (data) {
 
        })
    },
    data: {}
});


我请求后台的到的json怎么解析出来?
如果我想保存到变量 如 var b = json 需要怎么做呢?
方便以后调用,如:

new VUE({
    el:"#app",
    data:b
})

请教各位大虾!!

得到的json数据:


https://github.com/papersnake/newdenfaces-vue/blob/master/src/vuex/actions.js

直接研究一下吧,感觉缺乏的是基础知识


这样试试呢? 不过还是建议老老实实看文档。

new Vue({
    el: '#post_from2',
    ready: function () {
        var self = this;
        this.$http.post('./fun/post.php', {
            type: "sydata"
        }, {
            headers: {
                "X-Requested-With": "XMLHttpRequest"
            },
            emulateJSON: true
        }).then(function (data) {
            self.b = data;
        })
    },
    data: {
        b: {}
    }
});

记得貌似是this.$set("b",data)或者this.$data.b=data

【热门文章】
【热门文章】