Vue2.4.0+vue-source+express解决获取数据不成功问题

来源:互联网 发布:js 正则匹配数字 编辑:程序博客网 时间:2024/06/05 14:49

旧版本代码如下:

var vm=new Vue({        el:'.book',        data:{            books:[]        },        ready() {            this.resource=this.$resource("/books{/id}");            this.resource.get().then((data)=> {                this.books=data.json();            })        }    })

新版本代码如下:

var vm=new Vue({        el:'.book',        data:{            books:[]        },        mounted:function () {            this.resource=this.$resource("/books{/id}");            this.resource.get().then((data)=> {                this.books=data.body;                //this.books=[{"name":"vue","price":30},{"name":"js","price":10},{"name":"jquery","price":30}];            })        }    })

这里写图片描述

原创粉丝点击