TA的每日心情 | 开心 2016-5-25 21:56 |
---|
签到天数: 1 天 [LV.1]初来乍到
注册会员
- 积分
- 67
|
- <button class="btn">切换</button>
- <div class="swiper-container">
- <div class="swiper-wrapper">
- <div class="swiper-slide bg1">Slide 1</div>
- <div class="swiper-slide bg2">Slide 2</div>
- <div class="swiper-slide bg3">Slide 3</div>
- <div class="swiper-slide bg4">Slide 4</div>
- </div>
- <div class="swiper-button-prev control"></div>
- <div class="swiper-button-next control"></div>
- </div>
- </div>
- var swiper = new Swiper ('.swiper-container', {
- direction: 'horizontal',
- nextButton: '.swiper-button-next',
- prevButton: '.swiper-button-prev',
- noSwiping : true,
- spaceBetween: 10,
- slidesPerView: 3
- })
-
- $(".btn").click(function() {
- swiper.params.slidesPerView = 1;
- swiper.params.direction = 'vertical';
- swiper.slides.addClass('swiper-no-swiping');
- $('.control').hide();
- swiper.update();
- });
复制代码 demo:http://jsfiddle.net/knpaxzf6/
项目中一个需求是要让照片可以动态选择展示的方式,一种方式是横向滑动切换,另一种是竖直排列,
横向切换我用的是sipwer,我用上边的代码实现出现了问题,不知道是什么原因造成的,恳求各位前辈指点?
|
|