溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

微信小程序點擊頂部導航欄切換樣式代碼實例

發(fā)布時間:2020-10-02 20:37:21 來源:腳本之家 閱讀:195 作者:里哈哈T 欄目:web開發(fā)

這篇文章主要介紹了微信小程序點擊頂部導航欄切換樣式代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

類似這樣的效果

微信小程序點擊頂部導航欄切換樣式代碼實例

<view class='helpCateList'>
  <!-- 類別 -->
  <scroll-view class='scroll-view' scroll-x="true">
   <view class="item-content" wx:key="id" wx:for="{{helpCateList}}" wx:for-item="item">
    <view class="content {{currentTab == item.itemsId ? 'active' : ''}}" data-itemsId='{{item.itemsId}}' bindtap='cateChange' >{{item.itemsName}} </view>
   </view>
  </scroll-view>
 </view>
.helpDisList .content{
 position: relative;
 width: 710rpx;
 border-radius: 5rpx;

}
.active{ //當點擊的時候添加這個樣式
 /* border-bottom: 4rpx solid rgb(252, 186, 7); */
 color:rgb(252, 186, 7);
}
Page({
 data:{

  helpCateList:[ //數(shù)據(jù)從后臺請求回來賦值
   // { id: "1", desc: "康復醫(yī)療" },
   // { id: "2", desc: "教育" },
   // { id: "3", desc: "就業(yè)" },
   // { id: "4", desc: "扶貧" },
   // { id: "5", desc: "職業(yè)培訓" },
   // { id: "6", desc: "社會保障" },
   // { id: "7", desc: "文化生活" },
  ],
  currentTab: 1,
 },
 cateChange(e) {
  console.log(e)
  let that = this
  that.setData({

   currentTab: e.currentTarget.dataset.itemsid, //這個必須要

  })
 },

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節(jié)

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

AI