This repository has been archived on 2021-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
vuejs_course/2021-09-06_composition-17-r.../src/pages/AllProducts.vue

53 lines
853 B
Vue

<template>
<section>
<h2>All products</h2>
<ul>
<li v-for="product in products" :key="product.id">
<h3>{{ product.title }}</h3>
<h4>${{ product.price }}</h4>
<p>{{ product.description }}</p>
<router-link :to="'/products/' + product.id">View Details</router-link>
</li>
</ul>
</section>
</template>
<script>
import { inject } from 'vue';
export default {
setup() {
const loadedProducts = inject('products');
return { products: loadedProducts };
}
};
</script>
<style scoped>
section {
margin: 3rem auto;
max-width: 40rem;
padding: 1rem;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
margin: 1rem 0;
border: 1px solid #ccc;
padding: 1rem;
}
h3,
h4 {
margin: 0.5rem 0;
}
</style>