Advertisement
Guest User

q

a guest
Jul 25th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <template>
  2. <div class="home">
  3. <section class="hero is-medium is-dark mb-6">
  4. <div class="hero-body has-text-centered">
  5. <p class="title mb-6">
  6. Welcome to anime Djackets :)
  7. </p>
  8. <p class="subtitle">
  9. The best anime pictures
  10. </p>
  11. </div>
  12. </section>
  13.  
  14. <div class="column is-multiline">
  15. <div class="column is-12">
  16. <h2 class="is-size-2 has-text-centered">Latest products</h2>
  17. </div>
  18.  
  19. <div class="column is-3" v-for="product in latestProducts" v-bind:key="product.id">
  20. <div class="box">
  21. <figure class="image mb-4">
  22. <img :src="product.get_thumbnail" alt="">
  23. </figure>
  24.  
  25. <h3 class="is-size-4">{{product.name}}</h3>
  26. <p class="is-size-6 has-text-grey">${{product.price}}</p>
  27.  
  28. <router-link v-bind:to="product.get_absolute_url" class="button is-dark mt-4">View details</router-link>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34.  
  35. <script>
  36. // @ is an alias to /src
  37. import axios from 'axios'
  38. export default {
  39. name: 'HomeView',
  40. data() {
  41. return {
  42. latestProducts: []
  43. }
  44. },
  45. components: {
  46. },
  47. mounted() {
  48. this.getLatestProduct()
  49.  
  50. document.title = 'Home | DjangoAnime'
  51. },
  52. methods: {
  53. async getLatestProduct() {
  54. this.$store.commit('setIsLoading', true)
  55. await axios
  56. .get('/api/v1/latest-products/')
  57. .then(response => {
  58. this.latestProducts = response.data
  59. })
  60. .catch(error => {
  61. console.log(error )
  62. })
  63. this.$store.commit('setIsLoading', false)
  64. }
  65. }
  66. }
  67. </script>
  68.  
  69. <style scoped>
  70. .image {
  71. margin-top: -1.25rem;
  72. margin-left: -1.25rem;
  73. margin-right: -1.25rem;
  74. }
  75. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement