1.安装vue-resource模块
npm install vue-resource --save-dev
2.重启vue
npm run dev
3.在main.js中引入vue-resource模块
import VueResource from 'vue-resource'
5.在main.js中使用VueResource
Vue.use(VueResource)
6.在组件中通过生命周期钩子函数使用链接请求的数据(http://jsonplaceholder.typicode.com/ 有各种请求)
created() {
this.$http.get("http://jsonplaceholder.typicode.com/users")
.then((data) => {
this.users = data.body
})
}