预览图:

一、配置page.jsong中的tabbar(这一步是必须的,因为我们在使用uni.switchTab()时必须要用到)
"pagePath": "pages/index/index",
"iconPath": "static/images/icon/home.png",
"selectedIconPath": "static/images/icon/home_select.png",
"pagePath": "pages/OldGoods/OldGoods",
"iconPath": "static/images/icon/home.png",
"selectedIconPath": "static/images/icon/home_select.png",
"pagePath": "pages/list/list",
"pagePath": "pages/IntegralMall/IntegralMall",
"pagePath": "pages/me/me",
"iconPath": "static/images/icon/me.png",
"selectedIconPath": "static/images/icon/me_select.png",
二、编写tabbar组件
view:
<view class="center-btn-box">
<view class="center-btn" @click="SwitchTab('/pages/list/list',2)">
<image class="center-icon" src="../../static/images/label/cent_btn.png">image>
<view :class="['tab-item',pageindex===index?'action':'']" v-for="(item,index) in list" @click="SwitchTab(item.path,index)">
<image :src="pageindex===index?item.iconAction:item.icon" class="icon">image>
<view class="tab-name">{{item.title}}view>
css:这里就省略了,我中间那个其实就是用一个元素把中间那个选项给遮挡住,点击时使用uni.switchTab()仅此而已
js:我这里使用props属性的方式传值,因为点击时要做页面状态的切换,
icon:"../../static/images/label/tab_sy_01.png",
iconAction:"../../static/images/label/tab_sy_02.png",
path:"/pages/index/index?id=0"
icon:"../../static/images/label/tab_es_01.png",
iconAction:"../../static/images/label/tab_es_02.png",
path:"/pages/OldGoods/OldGoods"
icon:"../../static/images/label/tab_qy_01.png",
iconAction:"../../static/images/label/tab_qy_02.png",
icon:"../../static/images/label/tab_jf_01.png",
iconAction:"../../static/images/label/tab_jf_02.png",
path:"/pages/IntegralMall/IntegralMall"
icon:"../../static/images/label/tab_wd_01.png",
iconAction:"../../static/images/label/tab_wd_02.png",
使用组件:
<TabBar :pageindex="0">TabBar>
import TabBar from "@/components/TabBar/TabBar.vue"