在 swiper 初始化中
- var swiper1 = new swiper('#swiper1', {
- initialSlide: vm.initslide,
- spaceBetween: 15,
- slidesPerView: 'auto',// 加入这个属性
- });
加入注释的属性, 设置为 auto,
然后在用 dom 输出的 html 中:
- var swiper1_str = '';
- var gameList = data.data.gameList;
- for (var i = 0; i <gameList.length; i++) {
- swiper1_str += '<div class="swiper-slide"style="width:468px;height:296px"></div>';
- }
在 swiper-slide 的 div 中写入 style, 你需要确定的宽高. swiper 中的 swiper-slide 的宽高就可以固定了
来源: http://www.qdfuns.com/article/47925/ad8433ec6fb59369db1782b9e7179348.html