微信小程序滾動(dòng)Tab實(shí)現(xiàn)左右可滑動(dòng)切換-創(chuàng)新互聯(lián)

 微信小程序滾動(dòng)Tab實(shí)現(xiàn)左右可滑動(dòng)切換

江達(dá)網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),江達(dá)網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為江達(dá)成百上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的江達(dá)做網(wǎng)站的公司定做!

效果:

微信小程序滾動(dòng)Tab實(shí)現(xiàn)左右可滑動(dòng)切換

最終效果如上。問題:

1、tab標(biāo)題總共8個(gè),所以一屏無法全部顯示。
2、tab內(nèi)容區(qū)左右滑動(dòng)切換時(shí),tab標(biāo)題隨即做標(biāo)記(active)。
3、當(dāng)active的標(biāo)題不在當(dāng)前屏顯示時(shí),要使其能顯示到當(dāng)前屏中。

一、wxml結(jié)構(gòu)

tab標(biāo)題因一排八個(gè),所以使用 scroll-view組件,使其可橫向滾動(dòng)。

tab內(nèi)容可左右滑動(dòng)切換,使用swiper組件實(shí)現(xiàn)

為了偷懶,所以數(shù)據(jù)都通過wx:for遍歷重復(fù)出來。

說明:

1、設(shè)置data-current屬性用于:點(diǎn)擊當(dāng)前項(xiàng)時(shí),通過點(diǎn)擊事件swichNav中處理e.dataset.current取到點(diǎn)擊的目標(biāo)值。
2、swiper組件的current組件用于控制當(dāng)前顯示哪一頁
3、swiper組件綁定change事件switchTab,通過e.detail.current拿到當(dāng)前頁

<view >
  <scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}">
    <view class="tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="swichNav">健康</view>
    <view class="tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="swichNav">情感</view>
    <view class="tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="swichNav">職場(chǎng)</view>
    <view class="tab-item {{currentTab==3?'active':''}}" data-current="3" bindtap="swichNav">育兒</view>
    <view class="tab-item {{currentTab==4?'active':''}}" data-current="4" bindtap="swichNav">糾紛</view>
    <view class="tab-item {{currentTab==5?'active':''}}" data-current="5" bindtap="swichNav">青蔥</view>
    <view class="tab-item {{currentTab==6?'active':''}}" data-current="6" bindtap="swichNav">全部</view>
    <view class="tab-item {{currentTab==7?'active':''}}" data-current="7" bindtap="swichNav">其他</view>
  </scroll-view>
  <swiper class="tab-content" current="{{currentTab}}" duration="300" bindchange="switchTab"
   >
    <swiper-item wx:for="{{[0,1,2,3,4,5,6,7]}}">
      <scroll-view scroll-y="true" class="scoll-h" >
        <block wx:for="{{[1,2,3,4,5,6,7,8]}}" wx:key="*this">
          <view class="item-ans">
            <view class="avatar">
              <image class="img" src="/upload/otherpic13/avatar.png"></image>
            </view>
            <view class="expertInfo">
              <view class="name">歡顏</view>
              <view class="tag">知名情感博主</view>
              <view class="answerHistory">134個(gè)回答,2234人聽過 </view>
            </view>
            <navigator url="/pages/askExpert/expertDetail" class="askBtn">問TA</navigator> 
          </view>
        </block>
      </scroll-view>
    </swiper-item>
  </swiper>
</view>

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁名稱:微信小程序滾動(dòng)Tab實(shí)現(xiàn)左右可滑動(dòng)切換-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://bm7419.com/article0/dscioo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、域名注冊(cè)、網(wǎng)站收錄、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站策劃品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)