Closed sunmingtao closed 4 years ago
npm install --save vue-resource
main.js
import VueResource from 'vue-resource'; Vue.use(VueResource); Vue.http.options.root="http://localhost:8080"
App.vue
With root configured:
this.$http.get("leagues").then(response => { this.leagues = response.data });
Without root configured:
this.$http.get('https://age-pension.firebaseio.com/refData.json') .then(response => { return response.json(); }).then(data => { this.pensionReferenceData = data.pension; this.currencyReferenceData = data.currency; this.isDataFetched = true; }); this.$http.post('https://age-pension.firebaseio.com/refData.json', this.user) .then(response => { console.log(response); }, error => { console.log(error); });
Set up base URL
Vue.http.options.root = "https://age-pension.firebaseio.com/refData.json"
this.$http.get('').then(...);
npm install --save vue-resource
main.js
App.vue
With root configured:
Without root configured: