vue.js轮播图组件
Vue.js的Flickity (Flickity for Vue.js)
A Vue Component for Flickity.js
Flickity.js的Vue组件
Vue支持 (Vue support)
Supports only Vue >= 2
仅支持Vue> = 2
安装及使用 (Installation and usage)
See official documentation here.
请参阅此处的官方文档。
$ npm install vue-flickity --save
import Flickity from 'vue-flickity';
new Vue({
components: {
Flickity
},
data () {
return {
flickityOptions: {
initialIndex: 3,
prevNextButtons: false,
pageDots: false,
wrapAround: true
// any options from Flickity can be used
}
}
},
methods: {
next() {
this.$refs.flickity.next();
},
previous() {
this.$refs.flickity.previous();
}
}
});
<flickity ref="flickity" :options="flickityOptions">
<div class="carousel-cell">1</div>
<div class="carousel-cell">2</div>
<div class="carousel-cell">3</div>
<div class="carousel-cell">4</div>
<div class="carousel-cell">5</div>
</flickity>
<!-- if you don't want to use the buttons Flickity provides -->
<button @click="previous()">Custom Previous Button</button>
<button @click="next()">Custom Next Button</button>
翻译自: https://vuejsexamples.com/a-vue-slider-carousel-component-for-flickity-js/
vue.js轮播图组件