Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div class="home">
- <section class="hero is-medium is-dark mb-6">
- <div class="hero-body has-text-centered">
- <p class="title mb-6">
- Welcome to anime Djackets :)
- </p>
- <p class="subtitle">
- The best anime pictures
- </p>
- </div>
- </section>
- <div class="column is-multiline">
- <div class="column is-12">
- <h2 class="is-size-2 has-text-centered">Latest products</h2>
- </div>
- <div class="column is-3" v-for="product in latestProducts" v-bind:key="product.id">
- <div class="box">
- <figure class="image mb-4">
- <img :src="product.get_thumbnail" alt="">
- </figure>
- <h3 class="is-size-4">{{product.name}}</h3>
- <p class="is-size-6 has-text-grey">${{product.price}}</p>
- <router-link v-bind:to="product.get_absolute_url" class="button is-dark mt-4">View details</router-link>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- // @ is an alias to /src
- import axios from 'axios'
- export default {
- name: 'HomeView',
- data() {
- return {
- latestProducts: []
- }
- },
- components: {
- },
- mounted() {
- this.getLatestProduct()
- document.title = 'Home | DjangoAnime'
- },
- methods: {
- async getLatestProduct() {
- this.$store.commit('setIsLoading', true)
- await axios
- .get('/api/v1/latest-products/')
- .then(response => {
- this.latestProducts = response.data
- })
- .catch(error => {
- console.log(error )
- })
- this.$store.commit('setIsLoading', false)
- }
- }
- }
- </script>
- <style scoped>
- .image {
- margin-top: -1.25rem;
- margin-left: -1.25rem;
- margin-right: -1.25rem;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement