Last active
December 5, 2016 06:38
-
-
Save tankxxl/ac5727ca79b3a64b524d046111340a69 to your computer and use it in GitHub Desktop.
Swiper一行多列时,点击任何一个slide返回的activeIndex都是0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<swiper :options="moduleSwiperOption" class="moduleSwiper"> | |
<swiper-slide v-for="(slide, $index) in modules"> | |
<div class="slide">{{ slide.title }}</div> | |
</swiper-slide> | |
</swiper> | |
</div> | |
</template> | |
<script> | |
export default { | |
data () { | |
return { | |
modules: [ | |
{title:'新品', desc: 'desc 1' }, | |
{title:'热卖', desc: 'desc 2' }, | |
{title:'蛋糕', desc: 'desc 3' }, | |
{title:'面包', desc: 'desc 4' }, | |
{title:'礼品', desc: 'desc 5' }, | |
{title:'附近', desc: 'desc 4' } | |
], | |
moduleSwiperOption: { | |
// 如果你后续需要找到当前实例化后的swiper对象以对其进行一些操作的话,可以自定义配置一个名字 | |
name: 'moduleSwiper', | |
// 所有配置均为可选(同Swiper配置) | |
// autoplay: 3000, | |
direction : 'horizontal', | |
grabCursor : true, | |
setWrapperSize :true, | |
// autoHeight: true, | |
spaceBetween: 30, | |
slidesPerView: 6, | |
mousewheelControl : true, | |
observeParents:true, | |
// if you need use plugins in the swiper, you can config in here like this | |
debugger: true, | |
// swiper callbacks | |
onClick: (swiper, event) => { | |
console.log('Swiper-onClick.activeIndex:' + swiper.activeIndex) | |
} | |
} | |
} | |
} | |
} | |
</script> | |
<style> | |
.moduleSwiper { | |
height: 300px; | |
} | |
.slide { | |
height: 30px; | |
background: red; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment