Sto giocando con vueJS e sto cercando di recuperare alcuni dati da una richiesta Ajax.
Heres il mio codice:
new Vue({
el: '#recipeList',
ready: function() {
this.fetchRecipes();
},
methods: {
fetchRecipes: function() {
this.$http.get('/recipes/ajax', function (recipes) {
this.$set('recipes') = recipes;
});
}
}})
il codice HTML va bene, dubito che avete bisogno di vedere questo.
La documentazione dice che questo è come si fa una richiesta Ajax, tuttavia l'oggetto $ http non sembra essere impostato.
Qui è l'errore console che sto ricevendo:
TypeError: undefined is not an object (evaluating 'this.$http.get')
fetchRecipesapp.js:10
(anonymous function)vue.js:307
readyapp.js:5
_callHookvue.js:8197
readyvue.js:10169
$mountvue.js:10155
_initvue.js:8054
Vuevue.js:80
global codeapp.js:1
app.js:10