IndexPage.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <q-page>
  3. <div class="q-pa-md">
  4. <q-carousel
  5. animated
  6. v-model="slide"
  7. navigation
  8. infinite
  9. height="540px"
  10. :autoplay="2000"
  11. arrows
  12. transition-prev="slide-right"
  13. transition-next="slide-left"
  14. @mouseenter="autoplay = false"
  15. @mouseleave="autoplay = true"
  16. >
  17. <q-carousel-slide
  18. v-for="(item, index) in sliders"
  19. :key="index"
  20. :name="index"
  21. :img-src="item.imageUrl"
  22. class="cursor-pointer"
  23. @click="goToBlog(item.linkToBlog)"
  24. >
  25. <div class="q-mt-xl q-ml-xl absolute-left custom-caption">
  26. <div style="height: 100px"></div>
  27. <div class="text-h1 text-weight-bolder">{{ item.title }}</div>
  28. <div class="text-h5 text-weight-medium">{{ item.subTitle }}</div>
  29. </div>
  30. </q-carousel-slide>
  31. </q-carousel>
  32. </div>
  33. </q-page>
  34. </template>
  35. <script>
  36. import { ref, onMounted } from "vue";
  37. import { defineComponent } from "vue";
  38. import { api } from "boot/axios";
  39. export default defineComponent({
  40. name: "IndexPage",
  41. setup() {
  42. const sliders = ref([]);
  43. function goToBlog(url) {
  44. window.location.href = url;
  45. }
  46. function loadHomeSliders() {
  47. api
  48. .get("/api/public/pagecontent/homesliders")
  49. .then((response) => {
  50. sliders.value = response.data.data;
  51. console.log("sliders.value");
  52. console.log(sliders.value);
  53. // loadBlogList();
  54. })
  55. .catch((e) => {
  56. console.log(e);
  57. });
  58. }
  59. onMounted(() => {
  60. // we call "next()" method of our component
  61. loadHomeSliders();
  62. });
  63. return {
  64. slide: ref(1),
  65. autoplay: ref(true),
  66. sliders,
  67. goToBlog,
  68. };
  69. },
  70. });
  71. </script>
  72. <style lang="sass" scoped>
  73. .custom-caption
  74. text-align: left
  75. padding: 12px
  76. color: white
  77. </style>