Build The Homepage
Explore how to create a functional homepage for your e-commerce app by displaying product categories and items using reusable Vue.js components. Understand structuring the template with assets and data imports for an engaging customer interface.
We'll cover the following...
Start building the homepage
Right now, our homepage, Home.vue, is empty. It’s time to display some categories and products there.
We can save this image as “homepage.jpg” in the assets directory.
Let’s start building the homepage.
We’ll display the image at the top and display some categories and products at the bottom.
The script section
We’ll import baseURL, products, and categories from App.vue.
We’ll import ProductBox and CategoryBox from the components. That’s the power of component reusability.
We’ll display a maximum of six categories and eight products. Ideally, we should have another API that gives us the top products and categories with pagination. We might develop the API later.
The template section
Follow the steps below:
- We’ll display the image at the top.
- We’ll show the six categories in the middle.
- We’ll display a maximum of 8 products.
Below is the complete code of Home.vue with some styles:
Below is what the category section will look like.
Below is what the product section will look like.