v-swiper.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="v-swiper">
  3. <swiper :options="swiperOption">
  4. <swiper-slide v-for="(item,index) in imgs" :key="index" class="swiper-con">
  5. <img class="imgSty" :src="item">
  6. </swiper-slide>
  7. <div class="swiper-pagination" slot="pagination"></div>
  8. </swiper>
  9. </div>
  10. </template>
  11. <script>
  12. import 'swiper/dist/css/swiper.css'
  13. import {swiper, swiperSlide} from 'vue-awesome-swiper'
  14. export default {
  15. data () {
  16. return {
  17. imgs: [
  18. 'http://video.cgaii.com/images/slider_img/slider_1.jpg',
  19. 'http://video.cgaii.com/images/slider_img/slider_2.jpg',
  20. 'http://video.cgaii.com/images/slider_img/slider_3.jpg',
  21. 'http://video.cgaii.com/images/slider_img/slider_4.jpg',
  22. 'http://video.cgaii.com/images/slider_img/slider_5.jpg',
  23. 'http://video.cgaii.com/images/slider_img/slider_6.jpg',
  24. 'http://video.cgaii.com/images/slider_img/slider_7.jpg',
  25. 'http://video.cgaii.com/images/slider_img/slider_8.jpg'
  26. ],
  27. swiperOption: {
  28. // effect:'cube',
  29. loop: true,
  30. speed: 2000,
  31. autoplay: {
  32. delay: 0,
  33. disableOnInteraction: false
  34. },
  35. slidesPerView: 8,
  36. spaceBetween: 15,
  37. pagination: {
  38. el: '.swiper-pagination',
  39. type: ''
  40. },
  41. freeMode: true
  42. }
  43. }
  44. },
  45. components: {
  46. swiper,
  47. swiperSlide
  48. }
  49. }
  50. </script>
  51. <style type="text/css" scoped>
  52. .v-swiper {
  53. position: relative;
  54. top: -3.4em;
  55. }
  56. .imgSty {
  57. border-radius: 8px;
  58. width: 95%;
  59. }
  60. .swiper-container {
  61. height: 400px;
  62. }
  63. .swiper-con:nth-child(even){
  64. position: relative;
  65. top: 80px;
  66. }
  67. @media screen and (max-width: 768px) {
  68. .swiper-container{
  69. height: 200px;
  70. }
  71. }
  72. </style>
  73. <style type="text/css">
  74. .swiper-container-free-mode>.swiper-wrapper {
  75. -webkit-transition-timing-function: linear!important;
  76. -moz-transition-timing-function: linear!important;
  77. -ms-transition-timing-function: linear!important;
  78. -o-transition-timing-function: linear!important;
  79. transition-timing-function: linear!important;
  80. }
  81. </style>