Take a look at the documentation for display data: http://vuejs.org/guide/list.html
Jul 9, 2015
14
Level 4
Why won't vue display my data?
I'm playing with a simple cart system in Laravel, using PHPCart and Vue.js.
When the user hits my basket route, Vue.js gets the basket data:
new Vue({
el: '#basket',
ready: function(){
this.fetchBasket();
},
methods: {
fetchBasket: function(){
this.$http.get('/api/buy/getBasket', function(basketItems){
this.$set('basketItems', basketItems);
});
}
}
});
This grabs the data just fine, as I can see it in the Dev tools:
2: {id: "2", name: "Cremin", price: 35, quantity: "1"}
id: "2"
name: "Cremin"
price: 35
quantity: "1"
3: {id: "3", name: "Torphy", price: 35, quantity: "1"}
id: "3"
name: "Torphy"
price: 35
quantity: "1"
However, when I just try and echo out the data in a v-repeat:
<div id="basket">
<ul v-repeat="basketItems">
<li> name ( in @-prefaced curly brackets which the forum gets rid of, stupidly )</li>
</ul>
</div>
The page just displays 'name' in curly brackets. What am I missing? It's loading the Vue vendor file and script files fine, it's grabbing the data fine, and it should be binding to the basket div. There are no console errors.
Please or to participate in this conversation.