Skip to content

Commit

Permalink
chore: return product id in shopping cart example (vuejs#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiaking committed Oct 4, 2021
1 parent c0bad80 commit 8c1c5d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions examples/classic/shopping-cart/components/ShoppingCart.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div class="cart">
<h2>Your Cart</h2>
<p v-show="!products.length"><i>Please add some products to cart.</i></p>
<p v-show="!products.length">
<i>Please add some products to cart.</i>
</p>
<ul>
<li
v-for="product in products"
:key="product.id">
<li v-for="product in products" :key="product.id">
{{ product.title }} - {{ currency(product.price) }} x {{ product.quantity }}
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions examples/classic/shopping-cart/store/modules/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const getters = {
return state.items.map(({ id, quantity }) => {
const product = rootState.products.all.find(product => product.id === id)
return {
id: product.id,
title: product.title,
price: product.price,
quantity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div class="cart">
<h2>Your Cart</h2>
<p v-show="!products.length"><i>Please add some products to cart.</i></p>
<p v-show="!products.length">
<i>Please add some products to cart.</i>
</p>
<ul>
<li
v-for="product in products"
:key="product.id">
<li v-for="product in products" :key="product.id">
{{ product.title }} - {{ currency(product.price) }} x {{ product.quantity }}
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions examples/composition/shopping-cart/store/modules/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const getters = {
return state.items.map(({ id, quantity }) => {
const product = rootState.products.all.find(product => product.id === id)
return {
id: product.id,
title: product.title,
price: product.price,
quantity
Expand Down

0 comments on commit 8c1c5d9

Please sign in to comment.