Vue-resource

2017-01-13  本文已影响0人  奈何明月照沟渠

Elample


{ 
  // GET /someUrl 
  this.$http.get('/someUrl').then((response) => { 
  // success callback
 }, (response) => { 
// error callback
 });
}

在注册了VueResource后,给vue实例this扩展了$http对象,该对象具有ajax方法,在实例代码中get方法返回的对象具有then方法,promess

请求结果作为数据要和vue生命周期中的data结合使用。data可以响应数据的变化

上一篇 下一篇

猜你喜欢

热点阅读