国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微信小程序自定義tabbar【中間凸起樣式】

這篇具有很好參考價(jià)值的文章主要介紹了微信小程序自定義tabbar【中間凸起樣式】。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

微信小程序自定義tabBar樣式,選中后中間凸起

效果預(yù)覽

微信小程序自定義tabbar【中間凸起樣式】

微信開發(fā)文檔:自定義tabBar

一、配置信息

  • 在 app.json 中的 tabBar 中指定 custom 字段為 true【允許使用自定義 tabBar】

  • 在所有 tab 頁 json 中申明usingComponents 項(xiàng),或者在 app.json 中全局開啟

  • 在 list 中指定自己需要 tab

  • 示例

    "tabBar": {
        "custom": true,
        "color": "#515151",
        "selectedColor": "#DAA520",
        "backgroundColor": "#000000",
        "list": [
            {
                "pagePath": "pages/index/index",
                "text": "首頁"
            },
            {
                "pagePath": "pages/hospital/hospital",
                "text": "醫(yī)院"
            },
            {
                "pagePath": "pages/publish/publish",
                "text": "item3"
            },
            {
                "pagePath": "pages/popularization/popularization",
                "text": "科普"
            },
            {
                "pagePath": "pages/me/me",
                "text": "我的"
            }
        ]
    },
    "usingComponents": {},
    

二、添加 tabBar 代碼文件

在代碼根目錄下添加custom-tab-bar文件夾,并在該文件夾下新建 page,文件結(jié)構(gòu)如下

|-- cusotm-tab-bar
? ?? |-- index.js
?? ?? |-- index.json
? ??? |-- index.wxml
? ??? |-- index.wxss

三、編寫 tabBar 代碼

  1. wxml 代碼

    <!--custom-tab-bar/index.wxml-->
    <view class="tab-bar">
      <view wx:for="{{list}}" wx:key="index" class="tab-bar-item {{item.bulge?'bulge':''}}" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
        <view  wx:if="item.bulge" class="tab-bar-bulge"></view>
        <image class="image" src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
        <!-- <view  wx:if="{{item.text}}" style="color: {{selected === index ? selectedColor : color}}" class="tab-bar-view">{{item.text}}</view> -->
        <view  class="tab-bar-view" style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
      </view>
    </view>
    
  2. js 代碼

    // custom-tab-bar/index.js
    Component({
      data: {
        color: "#515151",
        selectedColor: "#DAA520",
        backgroundColor: "#ffffff",
        list: [
          {
            pagePath: "/pages/index/index",
            text: "首頁",
            iconPath: "/images/tabbar/index.png",
            selectedIconPath: "/images/tabbar/index-selected.png"
          },
          {
            pagePath: "/pages/hospital/hospital",
            text: "醫(yī)院",
            iconPath: "/images/tabbar/hospital.png",
            selectedIconPath: "/images/tabbar/hospital-selected.png"
          },
          {
            pagePath: "/pages/publish/publish",
            bulge:true,
            text: "發(fā)布",
            iconPath: "/images/tabbar/dog.png",
            selectedIconPath: "/images/tabbar/dog-selected.png"
          },
          {
            pagePath: "/pages/popularization/popularization",
            text: "科普",
            iconPath: "/images/tabbar/popularization.png",
            selectedIconPath: "/images/tabbar/popularization-selected.png"
          },
          {
            pagePath: "/pages/me/me",
            text: "我的",
            iconPath: "/images/tabbar/me.png",
            selectedIconPath: "/images/tabbar/me-selected.png"
          },
        ]
      },
      attached() {
      },
      methods: {
        switchTab(e) {
          const data = e.currentTarget.dataset
          const url = data.path
          wx.switchTab({url}) 
        }
      }
    })
    
  3. wxss 代碼

    .tab-bar {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      height: 50px;
      background: #FFF;
      display: flex;
      line-height: 1.2;
      padding-bottom: env(safe-area-inset-bottom);
      border-top: 1px solid #e6e6e6;
    }
    
    .tab-bar-item {
      flex: 1;
      text-align: center;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
    }
    
    .tab-bar-item .image {
      width: 26px;
      height: 26px;
    }
    .bulge {
      background-color: #FFF;
    }
    .bulge .tab-bar-bulge{
      position: absolute;
      z-index: -1;
      width: 64px;
      height: 64px;
      top: -24px;
      border-radius: 50%;
      border-top: 1px solid #e6e6e6;
      background-color: #FFF;
    }
    .bulge .image{
      position: absolute; 
      width: 50px;
      height: 50px;
      top: -16px;
    }
    .bulge .tab-bar-view{
      position: relative;
      bottom: -16px;
      margin-top: 4px;
    }
    
    .tab-bar-item .tab-bar-view {
      font-size: 12px;
      margin-top: 4px;
    }
    
    
  4. json 代碼

    {
      "component": true
    }
    

四、配置 tab 頁

在每一個(gè) tab 頁的onShow函數(shù)中寫入下面的代碼,其中 selected 的值為每個(gè) tab 的索引文章來源地址http://www.zghlxwxcb.cn/news/detail-496054.html

onShow: function () {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
        this.getTabBar().setData({
            // 首頁為 0
            selected: 0
        })
    }
},

獲取項(xiàng)目源代碼

??微信公眾號【京茶吉鹿】內(nèi)回復(fù)“微信小程序組件”??

到了這里,關(guān)于微信小程序自定義tabbar【中間凸起樣式】的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 小程序自定義tabbar,中間凸起

    微信小程序自帶tabbar,但無法實(shí)現(xiàn)中間按鈕凸起樣式和功能,因此按照設(shè)計(jì)重新自定義一個(gè)tabbar 如需源碼,請點(diǎn)擊下載源碼,或點(diǎn)擊頂部下載按鈕

    2024年02月08日
    瀏覽(20)
  • 鴻蒙開發(fā)自定義tabbar,帶中間凸起按鈕

    鴻蒙開發(fā)自定義tabbar,帶中間凸起按鈕

    今天要分享的是開發(fā)一個(gè)自定義tabbar,因?yàn)楹灹吮C軈f(xié)議的緣故,所以本項(xiàng)目還是基于鴻蒙4.0。 先看效果圖: 自己做的圖標(biāo)不太美觀,大家見諒哈哈哈。 這種帶中間凸起的tabbar在項(xiàng)目中非常常見,但是我研究了一下系統(tǒng)的tabbar是不支持這樣設(shè)置的,所以我們就自己開發(fā)一個(gè)

    2024年04月17日
    瀏覽(29)
  • 原生微信小程序自定義tabbar引入Color UI樣式

    原生微信小程序自定義tabbar引入Color UI樣式

    Color UI 是一款適應(yīng)于H5、微信小程序、安卓、ios、支付寶的高顏值,高度自定義的 Css 組件庫。本文介紹了原生微信小程序如何自定義 tabbar 并使用 Color UI 樣式 Color UI 的安裝請自行參考官方文檔,以下步驟以已安裝Color UI為前提 重點(diǎn):配置 tabbar.custom = true 在代碼根目錄下添加

    2024年02月03日
    瀏覽(34)
  • uni-app 微信小程序之自定義中間圓形tabbar

    uni-app 微信小程序之自定義中間圓形tabbar

    首先在 pages.json 文件中,新建一個(gè) tabbar 頁面 此頁面主要是寫 tabbar的html樣式和布局,引用主頁面代碼,通過 v-if 控制進(jìn)行展示 index , search , maim , news , me 一級頁面 css 樣式文件太多了就不貼出來了

    2024年02月03日
    瀏覽(102)
  • uniapp自定義tabbar(支持中間凸起,角標(biāo),動(dòng)態(tài)隱藏tab,全端適用)

    uniapp自定義tabbar(支持中間凸起,角標(biāo),動(dòng)態(tài)隱藏tab,全端適用)

    在使用uniapp進(jìn)行開發(fā)時(shí),tabbar是我們使用的很頻繁的一個(gè)組件,但是在特定的平臺(tái)會(huì)有一些使用上的限制,無法通過一套代碼來做通用平臺(tái)的適配。比如說中間按鈕凸起,動(dòng)態(tài)隱藏某個(gè)tab(不同角色展示不同功能),使用字體圖標(biāo),數(shù)字角標(biāo)等,這些功能不是所有平臺(tái)都支持

    2024年02月02日
    瀏覽(27)
  • uniapp開發(fā)小程序-實(shí)現(xiàn)中間凸起的 tabbar

    uniapp開發(fā)小程序-實(shí)現(xiàn)中間凸起的 tabbar

    1.首先在 pages.json 文件中進(jìn)行tabbar的樣式和列表配置,代碼如下: 2.在components文件中封裝一個(gè)Tabbar 組件,命名為 TabBar.vue 代碼如下: 3.在 mian.js 全局注冊組件 4.在頁面中使用組件

    2024年02月14日
    瀏覽(28)
  • 前端Vue自定義tabbar底部tabbar凸起tabbar兼容蘋果劉海屏小程序和APP

    前端Vue自定義tabbar底部tabbar凸起tabbar兼容蘋果劉海屏小程序和APP

    前端Vue組件化開發(fā):自定義tabbar組件的設(shè)計(jì)與實(shí)現(xiàn)??兼容蘋果劉海屏小程序和APP 摘要: 隨著前端開發(fā)技術(shù)的不斷發(fā)展,組件化開發(fā)成為了提高開發(fā)效率和降低維護(hù)成本的有效手段。本文將介紹一款基于Vue的前端自定義tabbar組件的設(shè)計(jì)與實(shí)現(xiàn),該組件具有單獨(dú)開發(fā)、單獨(dú)維護(hù)

    2024年02月11日
    瀏覽(23)
  • uniapp - [ H5 網(wǎng)頁 / App ] 高性能 tabbar 底部菜單凸起效果,原生系統(tǒng)自定義底部菜單不卡頓、切換頁面不閃爍、自動(dòng)緩存頁面(底部菜單中間自定義一個(gè)圖片并懸浮起來)

    uniapp - [ H5 網(wǎng)頁 / App ] 高性能 tabbar 底部菜單凸起效果,原生系統(tǒng)自定義底部菜單不卡頓、切換頁面不閃爍、自動(dòng)緩存頁面(底部菜單中間自定義一個(gè)圖片并懸浮起來)

    網(wǎng)上有很多自定義 tabbar 底部菜單的教程,但終歸是組件形式,避免不了切換頁面卡頓、閃屏閃爍、各平臺(tái)不兼容等一系列問題。 本文 基于 uniapp 系統(tǒng)原生 tabbar 底部菜單,植入一個(gè)向上凸起的 “圖片” 菜單,并支持點(diǎn)擊觸發(fā)事件, 您可以直接復(fù)制代碼,換個(gè)中間凸起的菜

    2024年02月21日
    瀏覽(37)
  • 微信小程序自定義tabBar

    微信小程序自定義tabBar

    首頁 分類 留言 我的 /components/index-tabbar/index.js Component({ properties: { active: { type: String, value: ‘index’ }, }, methods: { onChange(event) { wx.redirectTo({ url: /pages/${event.detail}/index , }) } } }) 模擬的 tabbar 頁面寫法如下: /pages/home/index.json { “usingComponents”: { “index-tabbar”: “/components/index-ta

    2024年04月24日
    瀏覽(64)
  • 微信小程序自定義tabBar使用

    微信小程序自定義tabBar使用

    自定義使用tabbar步驟 文章目錄 一、為什么要使用自定義tabBar? 二、使用步驟 總結(jié) 微信小程序官方默認(rèn)的tabbar有很多局限性,比如無法調(diào)整圖片和文字大小、不能動(dòng)態(tài)調(diào)整個(gè)數(shù)等。 小程序開發(fā)版本:RC Build?(1.06.2206271) 在小程序開發(fā)文檔中找到指南--》基礎(chǔ)能力--》自定義tab

    2024年02月09日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包