vue2 数据交互 vue-resource

1、安装vue-resource到项目中,找到当前项目

输入:npm install vue-resource --save

 

2、安装完毕后,在main.js中导入,如下所示:

import  VueResource  from 'vue-resource'

Vue.use(VueResource) 

 

3,数据调用

this.$http.get('/api/list').then((response)=>{
console.log(response.body)
})
posted @ 2017-12-29 14:24  ermao的博客  阅读(209)  评论(0编辑  收藏  举报