这个vue轮播插件只有10k大小,使用十分方便
先放官网的使用方法。
http://www.jianshu.com/p/e11505466851
import Vue from 'vue'
import Swiper from 'vue-swiper'
new Vue({
el: 'body',
components: {Swiper},
methods: {
onSlideChangeStart (currentPage) {
console.log('onSlideChangeStart', currentPage);
},
onSlideChangeEnd (currentPage) {
console.log('onSlideChangeEnd', currentPage);
}
}
});
ref:swiper
direction="horizontal"
:mousewheel-control="true"
:performance-mode="false"
:pagination-visible="true"
:pagination-clickable="true"
:loop=“true”
@slide-change-start="onSlideChangeStart"
@slide-change-end="onSlideChangeEnd">
Page 1
Page 2
Page 3
Api Properties
Name | Type | Default | Description |
---|---|---|---|
direction | String |
"vertical" |
Could be 'horizontal' or 'vertical' (for vertical slider). |
mousewheel-control | Boolean |
true |
Set to true to enable navigation through slides using mouse wheel. |
pagination-visible | Boolean |
false |
Toggle (hide/true) pagination container visibility when click on Slider's container |
pagination-clickable | Boolean |
false |
If true then clicking on pagination button will cause transition to appropriate slide. |
performace-mode | Boolean |
false |
Disable advance effect for better performance. |
loop | Boolean |
false |
Set to true to enable continuous loop mode |
==================== | ========= | ============ | =================== |
Method | Description |
---|---|
next() | Go next page. |
prev() | Go previous page. |
setPage(Number ) |
Set current page number. |
Name | Parameters | Description |
---|---|---|
slide-change-start | pageNumber |
Fire in the beginning of animation to other slide (next or previous). |
slide-change-end | pageNumber |
Will be fired after animation to other slide (next or previous). |
slide-revert-start | pageNumber |
Fire in the beginning of animation to revert slide (no change). |
slide-revert-end | pageNumber |
Will be fired after animation to revert slide (no change). |
slider-move | offset |
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. |
================== | ================ | ============================ |
v-ref:swipe
声明后就可以在vue.js中可以使用this.$refs.swipe
来调用next();
prev();
setPage(1);
等方法github地址
推荐阅读
- 【|eclipse工作空间配置拷贝
- 【|修复了Ubuntu诡异的变成了只读文件系统的错误
- 【Javascript点滴知识|从零发布TypeScript npm工具包
- 【Vue-Router点滴知识|vue-router 2.0 常用基础知识点之router-link
- 【Flutter点滴知识|Flutter 触摸事件监听 Listener 、手势识别示例