日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
微信小程序自定義tabbar高度
可以通過設置tabBarStyle屬性的height值來自定義微信小程序中的tabbar高度,tabBarStyle: { height: '80px' }

微信小程序自定義tabBar

微信小程序的tabBar是小程序底部的導航欄,可以放置最多5個tab,每個tab可以跳轉(zhuǎn)到對應的頁面,默認情況下,tabBar只有4個固定的tab:首頁、分類、購物車和個人中心,有時候我們需要自定義tabBar,以滿足特定的需求,本文將介紹如何在微信小程序中自定義tabBar。

自定義tabBar的基本思路

要自定義tabBar,我們需要完成以下步驟:

1、在app.json中配置tabBar屬性,設置自定義tabBar的相關參數(shù)。

2、在app.wxss中編寫自定義tabBar的樣式。

3、在頁面的js文件中,監(jiān)聽tabBar的相關事件,如點擊、切換等。

自定義tabBar的具體實現(xiàn)

1、配置app.json

在app.json中,我們需要配置tabBar的屬性,具體如下:

{
  "pages": [
    "pages/index/index",
    "pages/category/category",
    "pages/cart/cart",
    "pages/user/user",
    "pages/customTabBar/customTabBar"
  ],
  "window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "WeChat",
    "navigationBarTextStyle": "black"
  },
  "tabBar": {
    "color": "#999",
    "selectedColor": "#000",
    "backgroundColor": "#fff",
    "borderStyle": "black",
    "list": [
      {
        "pagePath": "pages/index/index",
        "text": "首頁",
        "iconPath": "images/home.png",
        "selectedIconPath": "images/homeactive.png"
      },
      {
        "pagePath": "pages/category/category",
        "text": "分類",
        "iconPath": "images/category.png",
        "selectedIconPath": "images/categoryactive.png"
      },
      {
        "pagePath": "pages/cart/cart",
        "text": "購物車",
        "iconPath": "images/cart.png",
        "selectedIconPath": "images/cartactive.png"
      },
      {
        "pagePath": "pages/user/user",
        "text": "個人中心",
        "iconPath": "images/user.png",
        "selectedIconPath": "images/useractive.png"
      }
    ]
  }
}

在上述代碼中,我們設置了tabBar的color、selectedColor、backgroundColor、borderStyle等屬性,以及一個list數(shù)組,用于存放自定義的tab,每個tab包含pagePath、text、iconPath和selectedIconPath四個屬性,pagePath表示頁面路徑,text表示tab的文字,iconPath表示未選中時的圖標,selectedIconPath表示選中時的圖標,注意,iconPath和selectedIconPath需要使用相對路徑。

2、編寫app.wxss樣式

在app.wxss中,我們可以編寫自定義tabBar的樣式。

/* tabBar */
.customtabbar {
  display: flex;
  justifycontent: spacearound;
  alignitems: center;
  height: 50px;
  backgroundcolor: #fff;
  bordertop: 1px solid #ccc;
}
.customtabbar .item {
  display: flex;
  flexdirection: column;
  alignitems: center;
}
.customtabbar .item span {
  fontsize: 12px;
  color: #999;
}
.customtabbar .item i {
  width: 24px;
  height: 24px;
}
.customtabbar .item i.home { backgroundimage: url(../../images/home.png); }
.customtabbar .item i.homeactive { backgroundimage: url(../../images/homeactive.png); }
.customtabbar .item i.category { backgroundimage: url(../../images/category.png); }
.customtabbar .item i.categoryactive { backgroundimage: url(../../images/categoryactive.png); }
.customtabbar .item i.cart { backgroundimage: url(../../images/cart.png); }
.customtabbar .item i.cartactive { backgroundimage: url(../../images/cartactive.png); }
.customtabbar .item i.user { backgroundimage: url(../../images/user.png); }
.customtabbar .item i.useractive { backgroundimage: url(../../images/useractive.png); }

在上述代碼中,我們?yōu)樽远x的tabBar添加了一個名為customtabbar的class,并為其設置了樣式,我們還為每個tab的圖標設置了背景圖片,注意,這里使用了相對路徑,如果需要使用絕對路徑,可以將url()中的路徑替換為實際的圖片路徑。


本文名稱:微信小程序自定義tabbar高度
URL分享:http://www.5511xx.com/article/djocpie.html