1. 程式人生 > >vue + swiper 實現圖片輪播

vue + swiper 實現圖片輪播

export default { data () { return { timer: null, //定時器 mark: 0, //比對圖片索引的變數 imgArray: [//圖片路徑 require('../../assets/images/index/banner1.png'), require('../../assets/images/index/banner1.png'), require('../../assets/images/index/banner1.png'), require('../../assets/images/index/banner1.png'
) ] } }, methods: { autoPlay () { this.mark++; if (this.mark === 4) { this.mark = 0 } }, play () { this.timer = setInterval(this.autoPlay, 2500) }, change (i) { this.mark = i }, stop () { clearInterval(this.timer) }, move () { this
.timer = setInterval(this.autoPlay, 2500) } }, created () { this.play() } }