autoHeight属性使用看官网的示例:https://www.swiper.com.cn/api/parameters/294.html
swiper的选项卡结构查看:https://www.swiper.com.cn/demo/indexsample/
swiper的tab的一般DOM节点为:
<body>
<div class="tabs">
<a href="#" class="active">选项卡1</a>
<a href="#" class="active">选项卡2</a>
...
</div>
<div class="swiper-contianer" id="container"> <!--外层容器一点要加上swiper-container类,否则autoHeight属性没有用--->
<div class="swiper-wrapper">
<div class="swiper-silde"></div>
<div class="swiper-silde"></div>
...
</div>
</div>
<script type="text/javascript">
var swiper = new Swiper(‘#container‘, {
autoHeight: true, //将autoHeight设置为true,则swiper-containe容器,swiper-warpper的高度将会随swiper-slide的高度而变化,自适应高度
});
</script>
</body>
原文地址:https://www.cnblogs.com/xiangxinhouse/p/9668906.html
时间: 2024-11-05 15:48:27