Skip to content

Commit dba4c84

Browse files
committed
chore: return product id in shopping cart example (#1918)
fix #1918
1 parent a9cc8ec commit dba4c84

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

examples/shopping-cart/components/ShoppingCart.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="cart">
33
<h2>Your Cart</h2>
4-
<p v-show="!products.length"><i>Please add some products to cart.</i></p>
4+
<p v-show="!products.length">
5+
<i>Please add some products to cart.</i>
6+
</p>
57
<ul>
6-
<li
7-
v-for="product in products"
8-
:key="product.id">
8+
<li v-for="product in products" :key="product.id">
99
{{ product.title }} - {{ product.price | currency }} x {{ product.quantity }}
1010
</li>
1111
</ul>

examples/shopping-cart/store/modules/cart.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const getters = {
1313
return state.items.map(({ id, quantity }) => {
1414
const product = rootState.products.all.find(product => product.id === id)
1515
return {
16+
id: product.id,
1617
title: product.title,
1718
price: product.price,
1819
quantity

0 commit comments

Comments
 (0)