|
1 | 1 | <template> |
2 | 2 | <div> |
3 | | - <div |
4 | | - id="hero" |
5 | | - class="flex w-full mx-auto mt-16 bg-right bg-cover md:pt-0 md:items-center" |
6 | | - > |
| 3 | + <swiper id="hero" ref="mySwiper" :options="swiperOption"> |
| 4 | + <swiper-slide |
| 5 | + ><img src="~assets/images/Hero.jpg" /> |
| 6 | + <div |
| 7 | + class="flex flex-col items-start justify-center w-full mx-auto tracking-wide lg:w-1/2" |
| 8 | + > |
| 9 | + <span |
| 10 | + class="w-full p-4 mt-4 text-center text-white bg-black text-md lg:text-2xl lg:-mt-64" |
| 11 | + > |
| 12 | + Modern Pillow Sample Set |
| 13 | + </span> |
| 14 | + </div> |
| 15 | + </swiper-slide> |
| 16 | + <swiper-slide |
| 17 | + ><img src="~assets/images/Hero2.jpg" /> |
| 18 | + <div |
| 19 | + class="flex flex-col items-start justify-center w-full mx-auto tracking-wide lg:w-1/2" |
| 20 | + > |
| 21 | + <span |
| 22 | + class="w-full p-4 mt-4 text-center text-white bg-black text-md lg:text-2xl lg:-mt-64" |
| 23 | + > |
| 24 | + Modern Interior Sample |
| 25 | + </span> |
| 26 | + </div> |
| 27 | + </swiper-slide> |
7 | 28 | <div |
8 | | - class="flex flex-col items-start justify-center w-full px-6 tracking-wide lg:w-1/2" |
9 | | - > |
10 | | - <span class="p-4 my-4 text-2xl text-white bg-black rounded-lg"> |
11 | | - Modern Pillow Sample Set |
12 | | - </span> |
13 | | - </div> |
14 | | - </div> |
| 29 | + slot="button-prev" |
| 30 | + class="swiper-button-prev" |
| 31 | + @click="swiper.slidePrev(1000, false)" |
| 32 | + ></div> |
| 33 | + <div |
| 34 | + slot="button-next" |
| 35 | + class="swiper-button-next" |
| 36 | + @click="swiper.slideNext(1000, false)" |
| 37 | + ></div> |
| 38 | + </swiper> |
15 | 39 | </div> |
16 | 40 | </template> |
17 | 41 |
|
18 | 42 | <script> |
| 43 | +import { Swiper, SwiperSlide } from 'vue-awesome-swiper' |
| 44 | +
|
| 45 | +import 'swiper/swiper-bundle.min.css' |
| 46 | +
|
19 | 47 | export default { |
20 | 48 | name: 'Hero', |
| 49 | + components: { |
| 50 | + Swiper, |
| 51 | + SwiperSlide, |
| 52 | + }, |
| 53 | + data() { |
| 54 | + return { |
| 55 | + swiperOption: { |
| 56 | + navigation: { |
| 57 | + nextEl: '.swiper-button-next', |
| 58 | + prevEl: '.swiper-button-prev', |
| 59 | + }, |
| 60 | + }, |
| 61 | + } |
| 62 | + }, |
| 63 | + computed: { |
| 64 | + swiper() { |
| 65 | + return this.$refs.mySwiper.$swiper |
| 66 | + }, |
| 67 | + }, |
| 68 | + mounted() { |
| 69 | + this.swiper.slideTo(2, 2000, false) |
| 70 | + }, |
21 | 71 | } |
22 | 72 | </script> |
23 | 73 |
|
24 | 74 | <style lang="postcss" scoped> |
25 | 75 | #hero { |
26 | | - background-image: url('~assets/images/Hero.jpg'); |
27 | | - height: 24rem; |
28 | 76 | max-width: 1350px; |
29 | 77 | } |
30 | 78 | </style> |
0 commit comments