76
rated 0 times
[
78]
[
2]
/ answers: 1 / hits: 16690
/ 8 Years ago, tue, february 16, 2016, 12:00:00
I keep getting the same error that this.list.$remove is not a function. I believe it has something to do with the html markup but not sure. Can anyone point me in the right direction? I have been struggling for the last 2 days.
Vue.component('cart-co', {
template: '#cart-template',
data: function() {
return {
list: []
}
},
ready: function() {
$.getJSON('cart/content', function(data) {
this.list = data;
}.bind(this));
},
methods: {
removeItem: function(item) {
console.log(item);
this.list.$remove(item);
}
}
});
new Vue({
el: 'body',
});
Here is my cart section:
<cart-co></cart-co>
<template id=cart-template>
<div class=cart-content-wrapper>
<div class=cart-content >
<ul v-if=list class=scroller style=height: 250px;>
<li v-for=item in list>
<a href=item.html><img src=assets/temp/cart-img.jpg alt= width=37 height=34></a>
<span class=cart-content-count>@{{ item.quantity }}</span>
<strong><a href=item.html>@{{ item.name }}</a></strong>
<em>@{{ item.price | currency }}</em>
<a href=# class=del-goods v-on:click=removeItem(item)><i class=fa fa-times></i></a>
</li>
</ul>
<ul v-else class=scroller style=height: 250px;>
<li>Shopping cart is empty</li>
</ul>
<div class=text-right>
<a href={{ route('cart.show-cart') }} class=btn btn-default>View Cart</a>
<a href=checkout.html class=btn btn-primary>Checkout</a>
</div>
</div>
</div>
</template>
More From » vue.js