欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序視圖容器(swiper)組件創(chuàng)建輪播圖

 更新時(shí)間:2022年04月07日 12:41:28   作者:Crazy Struggle  
這篇文章主要為大家詳細(xì)介紹了微信小程序視圖容器(swiper)組件創(chuàng)建輪播圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

 本文為大家分享了微信小程序swiper組件創(chuàng)建輪播圖的具體代碼,供大家參考,具體內(nèi)容如下

一、視圖容器(Swiper)

1、swiper:滑塊視圖容器

微信官方文檔

二、swiper應(yīng)用

1、頁面邏輯(index.js)

Page({
 data: {
 imgUrls: [
 {
 link: '/pages/index/index',
 url: '/images/001.jpg'
 }, {
 link: '/pages/list/list',
 url: '/images/002.jpg'
 }, {
 link: '/pages/list/list',
 url: '/images/003.jpg'
 }
 ],
 indicatorDots: true, //小點(diǎn)
 indicatorColor: "white",//指示點(diǎn)顏色
 activeColor: "coral",//當(dāng)前選中的指示點(diǎn)顏色
 autoplay: false, //是否自動(dòng)輪播
 interval: 3000, //間隔時(shí)間
 duration: 3000, //滑動(dòng)時(shí)間
 }

其中 imgUrls 是我們輪播圖中將要用到的 圖片地址和 跳轉(zhuǎn)鏈接

    indicatgorDots 是否出現(xiàn)焦點(diǎn)

    autoplay 是否自動(dòng)播放

    interval 自動(dòng)播放間隔時(shí)間

    duration 滑動(dòng)動(dòng)畫時(shí)間

2、頁面結(jié)構(gòu)(index.wxml)

<!--輪播圖-->
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="{{indicatorColor}}" 
 indicator-active-color="{{activeColor}}">
 <block wx:for="{{imgUrls}}">
 <swiper-item>
 <navigator url="{{item.link}}" hover-class="navigator-hover">
 <image src="{{item.url}}" class="slide-image" width="355" height="200" />
 </navigator>
 </swiper-item>
 </block>
</swiper>

注意:swiper 千萬不要在外面  加上任何標(biāo)簽 例如 <view> 之類的 ,如果加了可能會(huì)導(dǎo)致輪播圖出不來

3、頁面樣式(index.wxss)

/*輪播圖*/
.slide-image {
 width: 100%;
}

三、小程序效果圖

趕快動(dòng)手實(shí)踐就可以看到如圖所示效果圖:

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論