Skip to content

Instantly share code, notes, and snippets.

@magyarn
Created June 26, 2020 19:16
Show Gist options
  • Save magyarn/d68223558ada34e6351ab0e78c01d6cd to your computer and use it in GitHub Desktop.
Save magyarn/d68223558ada34e6351ab0e78c01d6cd to your computer and use it in GitHub Desktop.
<template>
<div>
<section class="wrapper">
<h2>Featured Items</h2>
<ul class="featured-items">
<li v-for="product in products" :key="product.id" class="featured-items__item">
<img class="product-image" :src="imagePath(product)" alt="">
<p class="product-title">{{ product.name }}</p>
<p><em>${{ product.price }}</em></p>
</li>
</ul>
</section>
</div>
</template>
<script>
export default {
name: 'home',
computed: {
products: function() {
return this.$store.state.products
}
},
methods: {
imagePath(product) {
return require(`../assets/img/products/${product.images[0]}`);
}
}
};
</script>
<style lang="scss">
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment