فهرست منبع

[ADD] listener for number input in cart item

Gogs 7 سال پیش
والد
کامیت
a2f0ca056b
1فایلهای تغییر یافته به همراه16 افزوده شده و 4 حذف شده
  1. 16 4
      src/components/cart/CartItem.vue

+ 16 - 4
src/components/cart/CartItem.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
         li.cart-item
             h3.item-name {{ item.display_name }}
-            input.item-quantity(:value="item.qty" number)
+            input.item-quantity(:value="quantity" v-model="quantity" number)
             span.item-x x
             span.item-price {{ formatPrice() }}
             span.item-equals =
@@ -28,9 +28,21 @@
                 }
             }
         },
-        computed: mapGetters([
-            'currencySymbol'
-        ]),
+        computed: {
+            quantity: {
+                get() {
+                    return this.item.qty || 1
+                },
+                set(value) {
+                    console.log(value)
+
+                    this.item.qty = value || 1
+                }
+            },
+            ...mapGetters([
+                'currencySymbol'
+            ])
+        },
         methods: {
             add(item) {
                 this.addToCart(item)