溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)的用法

發(fā)布時(shí)間:2021-01-06 10:19:34 來源:億速云 閱讀:552 作者:小新 欄目:移動(dòng)開發(fā)

小編給大家分享一下小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)的用法,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)

在<swiper-item>中用for循環(huán)傳入多個(gè)成對(duì)不同數(shù)據(jù)時(shí)的實(shí)現(xiàn)方法。

看下效果圖:

小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)的用法

遍歷實(shí)現(xiàn)方法:wxss省略:

wxml中代碼:

<!--導(dǎo)航部分輪播圖-->
<swiper class="navban" indicator-dots="{{indicatorDots}}" interval="{{interval}}" duration="{{duration}}">
    <swiper-item>
      <block wx:for="{{navs}}">
        <view class="navbox">
          <image class="navimg" src="{{item.navimg}}"></image>
          <text class="navtext">{{item.navtext}}</text>
        </view>
       </block>
    </swiper-item>  
</swiper>

相對(duì)應(yīng)js里面的代碼:

var app = getApp()
Page({
 data: {
  navs:[
   { navimg:'/images/i01.png', navtext:'掌上信息'},
   { navimg:'/images/i02.png', navtext:'商家'},
   { navimg:'/images/i03.png', navtext:'搶購(gòu)'},
   { navimg:'/images/i04.png', navtext:'搶福利'},
   { navimg:'/images/i05.png', navtext:'五折卡'},
   { navimg:'/images/i06.png', navtext:'黑貓活動(dòng)'},
   { navimg:'/images/i07.png', navtext:'本地圈'},
   { navimg:'/images/i08.png', navtext:'順風(fēng)車'},
  ],
  indicatorDots: true,
  autoplay: true,
  interval: 2000,
  duration: 1000,
 }
 
})

以上是“小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)的用法”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI