axios
import axios from 'axios';
axios.get('/users/addressList').then((response)=>{
var res = response.data;
this.addressList = res.result;
this.addressList.forEach((item,index)=>{
if(item.isDefault){
this.currentIndex = index;
this.selectedAddressId = item.addressId;
}
})
})
跨域
跨域post实例,用到了qs组件来避开ajax信使请求,并兼容Android。
import axios from 'axios';
import qs from 'qs';
axios.post('http://www.xyz.com/request', qs.stringify(params))
.then(response => {
console.log(response);
})
.catch(err => {
console.log(err);
});
vue-resource
this.$http.get...post...