Vue中如何使用vue-resource获取端口数据
1.npm install vue-resource
2.methods 中添加方法用来获取数据
getRoute:function(){
var that = this;
that.$http({
method:’GET’,
url:’http://rap.taobao.org/mockjsdata/17279/TNumberValue‘,
}).then(function(response){
// debugger
this.aboutData = response.body.data;
// console.log(this.aboutData);})
3.页面开始时调用该方法
- created:function(){
this.getRoute(),
},
在我的项目中 方法这样就可以调用获取数据了