swipe js dynamic content

來源:互聯網
上載者:User

標籤:

swipe js dynamic content 

swipe 動態改變內容時,需要用 update 一下。

 swiper.update(true);

 

執行個體:

HTML Code 

頁面用的FreeMarker渲染

<div class="swiper-container swiper-container-horizontal">
<ul class="swiper-wrapper">
<#if goods.productImages?has_content>
<#list goods.productImages as productImage>
<li pid="${productImage.productId}" class="swiper-slide">
<img src="${productImage.source}" >
</li>
</#list>
</#if>

</ul>
<!-- Add Pagination -->
<div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets">
<span class="swiper-pagination-bullet swiper-pagination-bullet-active"></span>
<span class="swiper-pagination-bullet"></span>
<span class="swiper-pagination-bullet"></span>
<span class="swiper-pagination-bullet"></span>
</div>
</div>
<script>
var swiper = new Swiper(‘.mSwiper .swiper-container‘, {
pagination: ‘.mSwiper .swiper-pagination‘,
paginationClickable: true
});
</script>

JavaScript Code  

// 商品圖片聯動    var changeProductImage = function(productId){
// 重新載入圖片 var $showProductImage = $("ul.swiper-wrapper"); $showProductImage.empty(); for (var i = 0; i < productImages.length; i++) { $showProductImage.append("<li pid=\""+productImages[i].productId+"\" class=\"swiper-slide\" style=\"width: 640px;\">"+ "<img src=\""+productImages[i].source+"\" alt=\"\"></li>"); } // 更新圖片輪播 swiper.update(true); };

  

註:主要用於商品圖片展示,當選擇不同顏色的商品,商品圖片要替換。

swipe js dynamic content

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.