This article mainly introduces the examples of vue using native swiper code. The article introduces the example code in detail, which has certain reference value for everyone's learning or work. Friends who need it can refer to it.
The code is as follows
<template> <div> <div class="swiper_Box" :class="identify"> <div class="swiper-wrapper" :ref="identify"> <div class="swiper-slide" v-for="(item,index) in imgArr" :key="'swiperSlide'+index"> <div class="bannerItem"> <img :src="" alt=""> </div> </div> </div> <!-- <div v-if=">1" class="swiper-button-prev" slot="button-prev"></div> <div v-if=">1" class="swiper-button-next" slot="button-next"></div> --> <div class="swiper-pagination"></div> </div> </div> </template> <script> export default { props:['imgArr','identify','paginationType'],//Receive the carousel picture from watch:{ imgArr:{ handler(newVal){ (newVal) }, immediate:true }, identify:{ handler(newVal){ ("id:"+newVal) var self=this; }, immediate:true } }, data(){ return{ swiperShow:false, MySwiper:null,//Swiper instance } }, created(){ }, mounted(){ var self=this; = new Swiper ('.'+,{ init: true, observer:true, observeParents:true, slidesPerView: 1, spaceBetween: 0, keyboard: { enabled: true, }, loop: true, autoplay: { delay: 8000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', clickable: true, type:?:'bullets' }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev' }, }); } } </script> <style scoped> @import url("../styles/"); /* Carousel picture */ .swiperBox{ width:100%; } .swiper_Box{ position: relative; overflow: hidden; } .swiper_Box .bannerItem img{ height:auto; width:100%; } .swiperBox .bannerItem{ width:100%; text-align: center; } .swiperBox .bannerItem img{ height:auto; width:100%; } .swiper-pagination{ position: absolute; bottom:20px; left:50%; transform: translateX(-50%); } </style>
The introduction form of swiper is the link tag introduction style
script tags to introduce js
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.