This is the default usage
<swiper>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
The swipers Switching direction,default is 'horizontal'.
Set direction to 'vertical'
<swiper direction="vertical">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
Set true to enable the loop mode
<swiper loop>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
type: [Boolean,Number] . if set true , it default to 3000,the unit is ms
<swiper loop :autoplay= 3000>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
Set paginationVisible and paginationClickable to true
<swiper pagination-visible pagination-clickable>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
swiper switching speed, type: Number
Set speed 1500
<swiper pagination-visible pagination-clickable :speed=1500>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
Set true to enable the mousewheelControl mode
<swiper mousewheel-control>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
if true, the swiper will not follow the move
<swiper performance-mode>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
The active page when initializing
:active-index=3
<swiper :active-index= 3>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
If you want the first page can not slide to left ,or the last page can not slide to right , you should set noBounds to true.
<swiper no-bounds>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
If true, you will not change the swiper by slide
<swiper pagination-visible pagination-clickable forbidden-slide>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
The tabMode should be an Array, if you set tabMode , it will add a tabnav above the swiper-slider.For better effect , you should also set forbidden-slide to true. If you just use the tab as a nav, you can set tabModeAnimation to true.
<swiper :tab-mode = "tabs" forbidden-slide>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
tabs: ['first','second','third']
just use the tab as a nav
<swiper :tab-mode = "tabs" tab-mode-animation>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
tabs: ['first','second','third']
<swiper :tab-mode = "tabs2" forbidden-slide>
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
tabs2: ['A','B','C']
If you want nest the swiper , you should add nested property to the children
<swiper no-bounds>
<div class="random-bg">page1</div>
<swiper nested :tab-mode="['2.1','2.2','2.3']">
<div class="random-bg">page2.1</div>
<div class="random-bg">page2.2</div>
<div class="random-bg">page2.3</div>
</swiper>
<div class="random-bg">page3</div>
</swiper>
Switch the swiper
<button @click="prev">prev</button><button @click="next">next</button>
<swiper direction="vertical" ref="switchDemo">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
methods:{
prev(){
this.$refs.switchDemo.prev()
},
next(){
this.$refs.switchDemo.next()
}
}
pageNumber: {type: Number}
noAnimation: {description:no transition animation when switching ,type: Boolean,default: true}
<button @click="toPage2">setPage(2,true)</button><button @click="toPage3">setPage(4,false)</button>
<swiper direction="vertical" ref="setPageDemo">
<div v-for="n in 4" class="random-bg">page {{n}}</div>
</swiper>
methods:{
toPage2(){
this.$refs.setPageDemo.setPage(2,true)
},
toPage4(){
this.$refs.setPageDemo.setPage(4,false)
}
}
Fire in the beginning of animation to other slide (next or previous). {param: pageNumber}
<swiper @slide-change-start="slideChangeStart">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
methods:{
slideChangeStart(number){
console.log('slide-change-start: ' + number)
}
}
Will be fired after animation to other slide (next or previous). {param: pageNumber}
<swiper @slide-change-end="slideChangeEnd">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
methods:{
slideChangeEnd(number){
console.log('slide-change-end: ' + number)
}
}
Fire in the beginning of animation to revert slide (no change). {param: pageNumber}
<swiper @slide-revert-start="slideRevertStart">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
methods:{
slideRevertStart(number){
console.log('slide-revert-start: ' + number)
}
}
Will be fired after animation to revert slide (no change). {param: pageNumber}
<swiper @slide-revert-end="slideRevertEnd">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
methods:{
slideRevertEnd(number){
console.log('slide-revert-end: ' + number)
}
}
Callback function, will be executed when user touch and move finger over Swiper and move it. Receives swiper instance and 'touchmove' event as an arguments. {param: offset}
<swiper @slider-move="sliderMove">
<div v-for="n in 3" class="random-bg">page {{n}}</div>
</swiper>
methods:{
sliderMove(offset){
console.log('slider-move: ' + offset)
}
}